Skip to content
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

Add support for git creation date #2579

Merged
merged 4 commits into from
May 2, 2021
Merged

Conversation

timvink
Copy link
Contributor

@timvink timvink commented Apr 19, 2021

Closes #2551

Copy link

@jaceklaskowski jaceklaskowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for nit-picking but spent too much time with doc writing and couldn't resist. HTH

docs/setup/adding-a-git-repository.md Outdated Show resolved Hide resolved
docs/setup/adding-a-git-repository.md Outdated Show resolved Hide resolved
docs/setup/adding-a-git-repository.md Outdated Show resolved Hide resolved
docs/setup/adding-a-git-repository.md Outdated Show resolved Hide resolved
@timvink
Copy link
Contributor Author

timvink commented Apr 22, 2021

Sorry for nit-picking but spent too much time with doc writing and couldn't resist. HTH

On the contrary, it shows you care. Much appreciated! Addressed the feedback in 33212c5

Copy link
Owner

@squidfunk squidfunk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking the time to add support for this nice little plugin 🚀 Going down the path of adding support for more and more git-related information, I'd suggest that we settle on a better naming scheme. I suggest the following steps:

  • Rename source-date.html into source-file.html(since this information is related to the current Markdown file). For downward compatibility until the next release, we keep source-date.html around and just include source-meta.html from there. In v8, we remove source-date.html

  • Come up with a better naming for the translation keys. The current scheme can't be generalized nicely. My proposal:

    • source.file.date.updated
    • source.file.date.created
    • source.file.author (if support is added in the future)

    This would also be consistent with the new name of the partial. For downard compatibility, we can keep source.revision.date until v8.

@timvink
Copy link
Contributor Author

timvink commented Apr 25, 2021

Nice improvement! Implemented in cee1eb4

@squidfunk squidfunk merged commit 1bb22ef into squidfunk:master May 2, 2021
@squidfunk
Copy link
Owner

Thanks again! It'll be included in the next release.

@squidfunk
Copy link
Owner

squidfunk commented May 2, 2021

Trying to test it, I'm getting this error:

  File "/mkdocs-material/venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/mkdocs-material/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
    return self.main(*args, **kwargs)
  File "/mkdocs-material/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
    rv = self.invoke(ctx)
  File "/mkdocs-material/venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/mkdocs-material/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/mkdocs-material/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
    return callback(*args, **kwargs)
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs/__main__.py", line 133, in serve_command
    serve.serve(
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 141, in serve
    config = builder()
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs/commands/serve.py", line 136, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs/commands/build.py", line 271, in build
    _populate_page(file.page, config, files, dirty)
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs/commands/build.py", line 167, in _populate_page
    page.markdown = config['plugins'].run_event(
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs_git_revision_date_localized_plugin/plugin.py", line 179, in on_page_markdown
    commit_timestamp=self.util.get_git_commit_timestamp(
  File "/mkdocs-material/venv/lib/python3.8/site-packages/mkdocs_git_revision_date_localized_plugin/util.py", line 166, in get_git_commit_timestamp
    return int(commit_timestamp)
ValueError: invalid literal for int() with base 10: '1594984107\n1590932441'

Just added it on Material for MkDocs' own repository.

@timvink
Copy link
Contributor Author

timvink commented May 2, 2021

Ah, I wouldn't have found that without running it on a large project. There are 2 creation dates: one when you created the creating-your-site.md in May 31st 2020, and another when you renamed the file (from docs/getting-started/creating-your-site.md → docs/creating-your-site.md ) on July 17th 2020.

Will make a fix and release soon.

@timvink
Copy link
Contributor Author

timvink commented May 2, 2021

OK, I released a new version (v0.9.2) that addresses this.

I haven't tried building material with npm (not sure how). Would appreciate if you can test locally. I pip install -e . on squidfunk:master and enabled the plugin with enable_creation_date=True in the mkdocs.yml file, and I get this error:

ERROR   -  Error building page 'changelog.md': source-file.html 

source-file.html

Not sure if that's an actual error, or me not having installed mkdocs-material properly from master. Can you check?

Stanzilla added a commit to Stanzilla/mkdocs-material that referenced this pull request May 2, 2021
@Stanzilla
Copy link
Contributor

@timvink try with #2627

@timvink
Copy link
Contributor Author

timvink commented May 3, 2021

@Stanzilla Thnx, but that PR will break compatiblity:

For downward compatibility until the next release, we keep source-date.html around and just include source-meta.html from there. In v8, we remove source-date.html (squidfunk)

That's why I went for this approach:

https://github.com/timvink/mkdocs-material/blob/cee1eb465d4a134d7f0e23f4a4885e02ecf70052/src/partials/source-date.html#L2-L3

@timvink
Copy link
Contributor Author

timvink commented May 3, 2021

I changed

{% include "source-file.html" %} 

to

{% include "partials/source-file.html" %} 

And that works for me. PR: #2629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add support for git creation date localized
4 participants