-
Notifications
You must be signed in to change notification settings - Fork 6
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
Making the version accessible to mkdocs as an "extra" property #7
Comments
If I understand correctly then your problem is to dynamically update extra properties in mkdocs.yaml First of all, don't forget to add macros plugin to your build python.pip 'mkdocs-macros-plugin:0.4.9' Then select some unique name for property: extra:
project_version: TBD So you could easily find and replace value: mkdocsBuild.doFirst {
def cfg = project.file(project.file(mkdocs.sourcesDir+'/mkdocs.yml'))
cfg.text = cfg.text.replaceAll(/(?m)project_version:.*/, "project_version:${project.version}":
} Should work. (plugin dynamically updates |
Hi @xvik, Thanks for that. I've done almost the same thing but used the |
The new version will provide direct support for variables with markdownextradata (installed by default, but not activated). In gradle, variables declared as: mkdocs {
extras = [
'version': "${-> project.version}",
'foo': 'some other value'
]
} Note that sensitive variables have to use closure notion in gstring to prevent immediate evaluation. mkdocs.yml must declare a new plugin: plugins:
- search
- markdownextradata Gradle plugin would generate Markdownextradata plugin will automatically load generated gradle file and so it would be possible to use declared properties in docs as Some static variables (not supposed to be changed by gradle) may be declared directly in mkdocs.yml in |
@xvik that's brilliant - thank you! |
What would be the easiest way of making the version accessible to mkdocs - I'm presuming as an "extra" property?
We plan on using the macros plugin to allow the version to be explicitly used in the text.
The text was updated successfully, but these errors were encountered: