-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add timestamp to generated docs #2465
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
Signed the CLA! |
@@ -311,6 +315,16 @@ case class Site(val root: JFile, val projectTitle: String, val documentation: Ma | |||
* defaults, the user-defined one will take precedence. | |||
*/ | |||
val layouts: Map[String, Layout] = { | |||
|
|||
val cal = Calendar.getInstance() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would recommend against using java.util.Date/Calendar/SimpleDataFormat. These APIs have many pitfalls and are not thread-safe. Java 8 introduced a new set of APIs to deal with date and time in the java.time
package that should be used instead. To get the current time you should use LocalDateTime.now: https://docs.oracle.com/javase/8/docs/api/java/time/LocalDateTime.html#now--
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much! Doing it right away!
val amOrPm = new SimpleDateFormat("a").format(today) | ||
val x = "<!-- generated on " + cal.get(Calendar.DATE) + "/"+ (cal.get(Calendar.MONTH)+1)+ "/"+cal.get(Calendar.YEAR) + " " + currentHour + ":" + currentMinute + ":" + amOrPm + "-->" | ||
var loc = root.getAbsolutePath.toString + "/.." + "/doc-tool/resources/_layouts/main.html" | ||
scala.tools.nsc.io.File(loc).appendAll(x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an alias for dotty.tools.io.File, use that instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again and Sorry. Regarding the failing tests, would it be better if I add a check for loc
over here?
CLA signed already, I dunno what the problem is... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not solve this by injecting the time into every main.html
file. Some people might not even be using said template.
This should be solved by using the infrastructure that templating provides. I.e:
<!-- generated on: {{ page.date | date: '%B %d, %Y' }} -->
It may be such that it is not set by default in page, and should if not exists be set to the current time (for posts it should be set in the preamble).
Regarding the signing, I can see that you have indeed signed. A rebase should fix this.
Noticed this just now, sorry! Would a tacky fix along the lines of |
@Varunram - we want to support people in doing something like:
Therefore it might be better to fill in the correct date in |
Pushed back irrelevant commits and did the requested changes. Thanks @felixmulder for helping me out 😄 |
LGTM, thanks @Varunram ! |
Intended as a solution to #2115.
Contrary to what was proposed back in the issue, appending at the end of the file seemed to be an easier alternative than reading from the file and rewriting - I'm new here, so please correct me if I'm wrong.