Skip to content

Comments

1350 support git revision date#1373

Merged
squidfunk merged 4 commits intosquidfunk:masterfrom
timvink:1350-support-git-revision-date
Dec 11, 2019
Merged

1350 support git revision date#1373
squidfunk merged 4 commits intosquidfunk:masterfrom
timvink:1350-support-git-revision-date

Conversation

@timvink
Copy link
Contributor

@timvink timvink commented Dec 9, 2019

Closes #1350

@squidfunk
Copy link
Owner

Wow, how did you manage to provide all the translations?

@timvink
Copy link
Contributor Author

timvink commented Dec 9, 2019

I'm good at languages 😋 Also trusted google translate here:

image

@squidfunk
Copy link
Owner

Very cool. Could we make the variable configurable? Currently there are five variables and only one is integrated into Material, so it's not possible to change by configuration, i.e. from you docs:

{{ git_revision_date_localized }}
{{ git_revision_date_localized_time }}
{{ git_revision_date_localized_iso }}
{{ git_revision_date_localized_iso_time }}
{{ git_revision_date_localized_timeago }}

Could we make that one variable which is set according to configuration? For example:

plugins:
  - git-revision-date-localized
    type: "date" | "time" | "iso_date" | "iso_time" | "timeago"

... with "date" being the default? Similar to the configuration of the search plugin.

@timvink
Copy link
Contributor Author

timvink commented Dec 9, 2019

Yes much cleaner, good idea. Will update package and this PR and let you know!

@squidfunk
Copy link
Owner

Looks great! Can you explain why there are two variables?

{% if page.meta.git_revision_date_localized %}
...
{% elif page.meta.revision_date %}
...

Also, could we change last.update to source.revision.date and put it in alphabetical order in the translation files (before toc.title)? I think that's a better fit. Otherwise LGTM!

@timvink
Copy link
Contributor Author

timvink commented Dec 9, 2019

All right v0.3.1 is published on pypi and add support for type variable.

I updated this PR, including the docs. Note I decided to also 'silently' support git-revision-date plugin with:

...
{% elif page.meta.revision_date %}
<small>{{ lang.t('last.update') }}: {{ page.meta.revision_date }} </small>
{% endif %}

It's undocumented & I was not sure if this is desirable functionality.

I tested these four variants:

  • both plugins set --> localized version used
  • localized plugin --> localized version used
  • git revision plugin --> Updated: YYYY-MM-DD displays in theme.language locale
  • no revision date plugin --> (default, same as now)

@timvink
Copy link
Contributor Author

timvink commented Dec 9, 2019

Also, could we change last.update to source.revision.date and put it in alphabetical order in the translation files (before toc.title)? I think that's a better fit. Otherwise LGTM!

On it!

@timvink
Copy link
Contributor Author

timvink commented Dec 9, 2019

Two more questions:

  1. On your docs you have a bitly link (reference) to open a new issue for a new translation file. It does not include the new source.revision.date item. Can you edit the link or shall I create a new bitly URL & update the docs? Alternatively.. can't we create a .github/ISSUE_TEMPLATE for this and then just link to new issue? Happy to provide a separate PR for this, or just do it here?
  2. I noticed you have the same files in both src/ and in material/. I had updated language and base.html in material/.. but now I found in your docs (here) that material is the results of npm run build? Should I move my updates to src/? Would it make sense to also clarify this in CONTRIBUTING.md for people less familiar with nodejs (like me)?

@squidfunk
Copy link
Owner

On your docs you have a bitly link (reference) to open a new issue for a new translation file. It does not include the new source.revision.date item. Can you edit the link or shall I create a new bitly URL & update the docs? Alternatively.. can't we create a .github/ISSUE_TEMPLATE for this and then just link to new issue? Happy to provide a separate PR for this, or just do it here?

Good catch, go for it. We should create a translate.md template. Wanted to do it for some time but haven't had the time. I switched to the more fine grained issue templates quite recently. A new bit.ly link should be created which points to the template and updated in the docs.

I noticed you have the same files in both src/ and in material/. I had updated language and base.html in material/.. but now I found in your docs (here) that material is the results of npm run build? Should I move my updates to src/? Would it make sense to also clarify this in CONTRIBUTING.md for people less familiar with nodejs (like me)?

The contributing section contains links to the guides for setting up the dev environment and the build process which contains a note on the automatically generated files, see this link. I've missed that you made your changes in the material folder, so yes, they must be done in the src folder. Each of the files you changed contains a header that says that the files are automatically generated 😉

{#-
  This file was automatically generated - do not edit
-#}

@timvink
Copy link
Contributor Author

timvink commented Dec 11, 2019

So I updated src/ now 🤦‍♂ Using source.revision.date and alphabetical order.

I'm having trouble running npm run build locally, getting weird code ELIFECYCLE errors. Let me know if this is important, I'll spend more time on it.

Also, did you see my comment on silently supporting mkdocs-git-revision-date-plugin (the {% elif %} statement)?

@squidfunk
Copy link
Owner

Awesome, thanks for your work! Will check it out and rebuild the theme.

I'm having trouble running npm run build locally, getting weird code ELIFECYCLE errors. Let me know if this is important, I'll spend more time on it.

No need to spend more time, but could you paste the actual error here?

Also, did you see my comment on silently supporting mkdocs-git-revision-date-plugin (the {% elif %} statement)?

Jep, sounds like a good idea.

@squidfunk squidfunk merged commit f08f2fb into squidfunk:master Dec 11, 2019
@squidfunk
Copy link
Owner

BTW, I just saw that the installation guide is missing the pip command. See the docs on PyMdown for an example.

@squidfunk
Copy link
Owner

Also, it's not working for me:

plugins:
  - git-revision-date-localized
(venv) squidfunk@squidfunk:mkdocs-material git:master:+1 > pip install mkdocs-git-revision-date-localized-plugin
Collecting mkdocs-git-revision-date-localized-plugin
  Downloading https://files.pythonhosted.org/packages/28/bf/798117664576ff80ad44008a34cdbda942c7096fde2bb4524876de14ba36/mkdocs_git_revision_date_localized_plugin-0.3.1-py3-none-any.whl
Collecting GitPython
  Downloading https://files.pythonhosted.org/packages/20/8c/4543981439d23c4ff65b2e62dddd767ebc84a8e664a9b67e840d1e2730d3/GitPython-3.0.5-py3-none-any.whl (455kB)
     |████████████████████████████████| 460kB 2.2MB/s 
Collecting babel>=2.7.0
  Downloading https://files.pythonhosted.org/packages/2c/60/f2af68eb046c5de5b1fe6dd4743bf42c074f7141fe7b2737d3061533b093/Babel-2.7.0-py2.py3-none-any.whl (8.4MB)
     |████████████████████████████████| 8.4MB 26.0MB/s 
Requirement already satisfied: jinja2 in ./venv/lib/python3.7/site-packages (from mkdocs-git-revision-date-localized-plugin) (2.10.3)
Collecting timeago>=1.0.10
  Downloading https://files.pythonhosted.org/packages/30/18/8e9e4b5671d246deb6b7f1ab481404f08cf082fccd08ac5870522eb5dcc2/timeago-1.0.10-py3-none-any.whl
Requirement already satisfied: mkdocs>=0.17 in ./venv/lib/python3.7/site-packages (from mkdocs-git-revision-date-localized-plugin) (1.0.4)
Collecting gitdb2>=2.0.0
  Downloading https://files.pythonhosted.org/packages/03/6c/99296f89bad2ef85626e1df9f677acbee8885bb043ad82ad3ed4746d2325/gitdb2-2.0.6-py2.py3-none-any.whl (63kB)
     |████████████████████████████████| 71kB 11.0MB/s 
Collecting pytz>=2015.7
  Using cached https://files.pythonhosted.org/packages/e7/f9/f0b53f88060247251bf481fa6ea62cd0d25bf1b11a87888e53ce5b7c8ad2/pytz-2019.3-py2.py3-none-any.whl
Requirement already satisfied: MarkupSafe>=0.23 in ./venv/lib/python3.7/site-packages (from jinja2->mkdocs-git-revision-date-localized-plugin) (1.1.1)
Requirement already satisfied: tornado>=5.0 in ./venv/lib/python3.7/site-packages (from mkdocs>=0.17->mkdocs-git-revision-date-localized-plugin) (6.0.3)
Requirement already satisfied: livereload>=2.5.1 in ./venv/lib/python3.7/site-packages (from mkdocs>=0.17->mkdocs-git-revision-date-localized-plugin) (2.6.1)
Requirement already satisfied: Markdown>=2.3.1 in ./venv/lib/python3.7/site-packages (from mkdocs>=0.17->mkdocs-git-revision-date-localized-plugin) (3.1.1)
Requirement already satisfied: click>=3.3 in ./venv/lib/python3.7/site-packages (from mkdocs>=0.17->mkdocs-git-revision-date-localized-plugin) (7.0)
Requirement already satisfied: PyYAML>=3.10 in ./venv/lib/python3.7/site-packages (from mkdocs>=0.17->mkdocs-git-revision-date-localized-plugin) (5.2)
Collecting smmap2>=2.0.0
  Downloading https://files.pythonhosted.org/packages/55/d2/866d45e3a121ee15a1dc013824d58072fd5c7799c9c34d01378eb262ca8f/smmap2-2.0.5-py2.py3-none-any.whl
Requirement already satisfied: six in ./venv/lib/python3.7/site-packages (from livereload>=2.5.1->mkdocs>=0.17->mkdocs-git-revision-date-localized-plugin) (1.13.0)
Requirement already satisfied: setuptools>=36 in ./venv/lib/python3.7/site-packages (from Markdown>=2.3.1->mkdocs>=0.17->mkdocs-git-revision-date-localized-plugin) (42.0.2)
Installing collected packages: smmap2, gitdb2, GitPython, pytz, babel, timeago, mkdocs-git-revision-date-localized-plugin
Successfully installed GitPython-3.0.5 babel-2.7.0 gitdb2-2.0.6 mkdocs-git-revision-date-localized-plugin-0.3.1 pytz-2019.3 smmap2-2.0.5 timeago-1.0.10
(venv) squidfunk@squidfunk:~/Desktop/General/Sources/mkdocs-material git:master:+1 > mkdocs serve          
INFO    -  Building documentation... 
ERROR   -  Config value: 'plugins'. Error: Invalid Plugins configuration 

Aborted with 1 Configuration Errors!
(venv) squidfunk@squidfunk:mkdocs-material git:master:+2 > mkdocs serve
INFO    -  Building documentation... 
ERROR   -  Config value: 'plugins'. Error: The "git-revision-date-localized" plugin is not installed 

Aborted with 1 Configuration Errors!

@squidfunk
Copy link
Owner

Okay, so maybe it had something to do with my Python environment. Gosh, I hate how Python didn't solve this in a way that is easy up to now (as opposed to npm). If I activate the plugin via plugins, I get:

INFO    -  Building documentation... 
INFO    -  Cleaning site directory 
ERROR   -  Error reading page 'customization.md': no loader for this environment specified 
Traceback (most recent call last):
  File "./venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/click/core.py", line 764, in __call__
    return self.main(*args, **kwargs)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/click/core.py", line 717, in main
    rv = self.invoke(ctx)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/click/core.py", line 1137, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/click/core.py", line 956, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/click/core.py", line 555, in invoke
    return callback(*args, **kwargs)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/mkdocs/__main__.py", line 134, in serve_command
    livereload=livereload
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 119, in serve
    config = builder()
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/mkdocs/commands/serve.py", line 114, in builder
    build(config, live_server=live_server, dirty=dirty)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/mkdocs/commands/build.py", line 274, in build
    _populate_page(file.page, config, files, dirty)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/mkdocs/commands/build.py", line 174, in _populate_page
    'page_markdown', page.markdown, page=page, config=config, files=files
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/mkdocs/plugins.py", line 94, in run_event
    result = method(item, **kwargs)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/mkdocs_git_revision_date_localized_plugin/plugin.py", line 67, in on_page_markdown
    return Template(markdown).render({'git_revision_date_localized': revision_date})
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
    return original_render(self, *args, **kwargs)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
    return self.environment.handle_exception(exc_info, True)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/Users/squidfunk/Desktop/General/Sources/mkdocs-material/venv/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
    raise value.with_traceback(tb)
  File "<template>", line 137, in top-level template code
TypeError: no loader for this environment specified

If I remove the plugin, everything is fine.

@timvink
Copy link
Contributor Author

timvink commented Dec 11, 2019

That's annoying.. will look in to it asap (later today)

@squidfunk
Copy link
Owner

squidfunk commented Dec 11, 2019

Note: I installed in a clean virtual environment. Python version is 3.7. What I did was:

virtualenv venv
. venv/bin/activate
pip install -r requirements.txt
pip install mkdocs-git-revision-date-localized-plugin
mkdocs serve

@timvink
Copy link
Contributor Author

timvink commented Dec 11, 2019

  • I'll update the docs with installation instructions in a separate PR.
  • As you can see I opened a separate issue because it is not related to mkdocs-material. Let's discuss there

StanzillaManticore pushed a commit to ManticoreGamesInc/mkdocs-material that referenced this pull request Dec 11, 2019
…k#1373)

* squidfunk#1350 update base template to include git revision date

* squidfunk#1350 add localized revision date

* squidfunk#1350 support for v0.3 of mkdocs-git-revision-date-localized-plugin

* squidfunk#1350 add translations for source.revision.date
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 mkdocs-git-revision-date-plugin

2 participants