Closed connerxyz closed 3 years ago
Ahh. I figured out why at least... I copy the files into docs-source/
from another directory... this other directory is where they are actually version controlled. Duh.
I was able to solve this by using the Util
class and computing timeago myself.
# Roughly what I did...
from mkdocs_git_revision_date_localized_plugin.util import Util
u = Util()
...
unix_timestamp_last_updated = u.get_git_commit_timestamp(path=path)
date_last_updated = datetime.datetime.fromtimestamp(unix_timestamp_last_updated)
print(timeago.format(date_last_updated, datetime.datetime.now()))
Bit puzzled by this one though.
This plugin uses the on_page_markdown event to retrieve the absolute path of a markdown source file, and then extracts the date by running git commands on them:
So a nested structure should not be an issue.
Which command do you use to build your docs? Do you define a docs_dir
in your mkdocs.yml
?
Not OP but I had the same question today and this issue helped me realize what was happening.
In my case, the site has a combination of auto-generated docs from a PowerShell module, and manually created pages. The module docs are version controlled under docs/ (this was the path prior to starting to use mkdocs) while the content of the site is under mkdocs/ as it was easier to give mkdocs a custom docs folder name than to modify the build step to generate docs in a subfolder of docs.
The contents at docs/en-US/*.md are copied to to mkdocs/functions prior to invoking mkdocs so there is no git history for the files in that folder when mkdocs runs.
Going forward, I'll customize the build-step for generating/updating the PowerShell docs so I can have them placed directly in the mkdocs build folder rather than copy the latest versions of them over at build time.
I'm looking to resolve getting warnings that git logs cannot be found for any files.
I thought it was my directory structure, which is non-standard, where we have MkDocs nested one level.
I tried copying
root/.git
todocs-source
to test this, but got the same result.Any advice? Thanks.