Comments (8)
I've opened two PRs that will address this issue. Waiting for the PR to gen-files
to be merged & released before I can add support to this plugin
from mkdocs-git-revision-date-localized-plugin.
Exclude supports globbing, do you know the directory ?
So you want to use --strict.. would a new option not to raise any warnings help?
from mkdocs-git-revision-date-localized-plugin.
Exclude supports globbing, do you know the directory ?
No, I don't know the directory. It has a random identifier that changes on every run of mkdocs build
would a new option not to raise any warnings help?
I believe it would be best not to raise a warning in this case. The behavior has to be requested explicitly by setting fallback_to_build_date: true,
so users should know what to expect. I would use warnings only for situations that may cause unintended behavior.
What do you think about it? If you agree to remove the warning, I'll be happy to prepare a pull request.
from mkdocs-git-revision-date-localized-plugin.
to auto-generate references from Python doc strings
Not sure if you're aware, but checkout mkdocstrings if you haven't already.
Another thought. What does your mkdocs.yml
plugin section look like? I suspect you have gen-files
before this plugin. Can you try switching the order? If that solves the problem, I can use the new (as of mkdocs 1.4) event priorities to ensure correct execution order.
But that's unlikely to work, considering the event tree: gen-files
uses the on_files
event, and this plugin mainly uses the on_page_markdown
event.
I still think the proper way is to exclude certain files and/or directories from this plugin. This is the logic currently used:
It might be that these generated files do not have a page.file.src_path
attribute. But that seems unlikely because the files are generated properly using the mkdocs File
class, so that attribute should be set: https://github.com/oprypin/mkdocs-gen-files/blob/b1d62c1e3193ddddb2f33599c4538792e7e838d5/mkdocs_gen_files/editor.py#L42-L47
A more obvious route might to add a PR to mkdocs-gen-files-plugin
that adds an attribute to generated pages, something inserting after this line the following:
new_f.generated_by_gen_files = True
Then we can build support for gen-files
into this plugin by testing during exclusion if hasattr(page.file, "generated_by_gen_files")
. That way, 1) we avoid adding extra options to this plugin, 2) new users will not have to worry about the setup but it works first time.
Thoughts?
from mkdocs-git-revision-date-localized-plugin.
Not sure if you're aware, but checkout mkdocstrings if you haven't already.
I use gen-files
and mkdocstrings
precisely as described in this recipe.
I suspect you have
gen-files
before this plugin.
I tried all possible positions before posting this issue. The error is always the same regardless of where I place git-revision-date-localized
in the plugins section.
I'll try what you've proposed above later today or tomorrow.
from mkdocs-git-revision-date-localized-plugin.
I would like to reopen this topic. We should either adopt the generated_by
field as a new field in File
over at MkDocs
, or this plugin should check if a file is actually located inside the project directory before trying to get the git history. I've just refactored the blog plugin and kind of regard this as a hack, as we're adding a field that is not part of the typings.
Checking if a file is located inside the project:
import os
def is_in_project(self, file: File, config: MkDocsConfig):
path = os.path.dirname(config.config_file_path)
return file.abs_src_path.startswith(path)
What do you think? I don't expect MkDocs adopting this in the near future.
from mkdocs-git-revision-date-localized-plugin.
It would make sense: if we can't find the file, then don't attempt to use git. But using the config_file_path to determine the directory is also hacky; there are too many edge cases. Top of mind, some things that could happen:
- symlinks
- git submodules
- users that have somehow moved their config files (or use plugins to have multiple config files)
- users that (perhaps through plugins) copy/move files to other (perhaps temporary) directories
- users that overwrite the
abs_src_path
attribute
I could spend more time looking for examples and corresponding reasons why, to see if these hold, but I currently don't trust the location of the config enough to infer location of other files.
MkDocs to adopting a generated_by
would be a better solution. I've opened mkdocs/mkdocs#3344 to start the discussion there.
from mkdocs-git-revision-date-localized-plugin.
Thanks for taking the time to investigate and the work on the PR! I understand that explicit is always better than implicit, and adding the respective field would also allow other plugins to adjust more easily.
from mkdocs-git-revision-date-localized-plugin.
Related Issues (20)
- The plugin breaks with the last mkdocs docker image HOT 3
- The plugin breaks with squidfunk/mkdocs-material:9.0.3 HOT 1
- Is there a way to turn off warnings? HOT 4
- Improve error message for dubious git ownership HOT 2
- if a file has no git logs, use the last modified timestamp instead of the current HOT 4
- which themes will this plugin work?
- Feature request: exclude specific commits when calculating the 'last update' calculation HOT 3
- Poor performance on large monorepos HOT 3
- Timeago setting results in incorrect items being added to extra_javascript HOT 2
- Create date not correct on Github pages HOT 4
- Document how to use sparse checkouts
- correctly populate `lastmod` of `sitemap.xml` HOT 2
- DeprecationWarning: datetime.datetime.utcfromtimestamp() is deprecated and scheduled for removal in a future version HOT 1
- Cloudflare Pages fetch-depth HOT 6
- 1.2.3 breaks integration with Material for MkDocs HOT 5
- Whitelist / Negate certain excludes with a `!`? HOT 1
- Feature Request: Show datetime on hover when using timeago
- DeprecationWarning when using Mldocs Material 9.5.20 and Mkdocs 1.60 HOT 4
- The creation date of the date plug-in seems to be incorrectly displayed HOT 1
- Use `packaging` package for backwards compatibility check
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mkdocs-git-revision-date-localized-plugin.