alphagov / alphagov/tech-docs-gem
Accept last_reviewed_on field as a string input
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 16
- Forks
- 47
- Avg merge
- 1d 21h
- Merged PRs (30d)
- 14
Description
What should change
Accept the use of last_reviewed_on field as a string input in any string variation; 2021/02/23, March 2027 23, January 13 2020, rather than a Date data type only. Whilst updating dependencies in the repositories listed in the next section I have found exceptions regarding the last_reviewed_on field as shown here. It appears that middleman expects the Date to be 2021/02/23 as highlighted on this page but the embedded ruby in this repository expects it to be 2021-02-23 as a Date object. As this field causes an exception it makes the title field fail causing the real error to be hidden by middleman asking for H1 tags when <%= current_page.data.title %> is used in the html file.
It currently fails here and the fix is to accept the string that is converted to a Date object:
def format_string_date(string_date)
Date.parse(string_date)
end
User need
At MoJ we are using the tech-docs-gem in this repository to publish our template documents based on this template repository. We have many html pages that are utilising the tech-docs-gem to generate the html sites.
I have modified the tech-docs-gem ruby code and tested it works with both a string and a Date object.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at lib/govuk_tech_docs.rb around line 82, where last_reviewed_on currently fails when supplied as a string. Review how the field is handled for Date objects, then verify the documented date variations and existing Date input no longer raise an exception or hide title rendering errors.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- documentation
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100