-
Notifications
You must be signed in to change notification settings - Fork 1.7k
What's the best way to add version/commit signature to docs? #494
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
Comments
Hi @behnam
Currently one just builds mdbook against different versions and publishes the artifacts under different dirs/paths in the webserver. mdBook works here like any other static site generator.
It sure is! Just have a travis build publish to different dirs/urls (ie. in single travis build you can generate several mdBooks sequentially put it different dirs).
As described above, mdBook does not understand any versioning or identifiers and I'm not entirely convinced that it should. The only relatively clean solution that come to my mind is to have optional parameter for mdBook that could incorporate any string into some stylized caption at the bottom of the sidebar. |
You already have the ability to add custom CSS and JS which will be used by the generated book as well as the ability to tweak the template being used. It would probably be better to leverage a more general solution like that instead of adding corner cases to the HTML renderer. We may need to make it easier to work with custom templates/css/js though. At the moment tweaking the generated output feels a lot harder than it should be... |
I did not mean to add any corner cases to the HTML renderer itself. Possibly some way to give key value pairs at commandline to include in hbs if given key is present. With the custom js you'd have to generate the included js file from some template to pass the commit/version string from outside env. |
Did a quick and simple manual version of this in for our mdbooks in our CI where we on some of our pages have a footer-like section that looks like this: ---
{{#include ../../../generated-version.md}} And then in CI simply before generating the docs we create that file with the info: printf "Generated on %s with \`%s\`" $(date -u +"%Y-%m-%dT%H:%M:%SZ") $(git rev-parse HEAD) > generated-version.md Which then looks like this: Could be styled up further with CSS to have smaller text. Would be nice to have some proper footer file support in mdbook to include it there (or in sidebar) |
I'm using the following hack to render the version at the beginning of every book page.
|
551: Display git version & date to introduction section r=jonas-schievink a=justahero This change is to know which specific commit of the book is published on the official site: https://defmt.ferrous-systems.com/ **Note** the `sed` command is written to work on OSX (the extra `.bak` parameter) and Unix systems, for some details check this [SO discussion](https://stackoverflow.com/questions/4247068/sed-command-with-i-option-failing-on-mac-but-works-on-linux) * add mdbook preprocessor to replace the version placeholder string with the used git version & date * add short section in the introduction to display version Reference: * [issue 494 discussion](rust-lang/mdBook#494) in the official mdbook repository Co-authored-by: Sebastian Ziebell <[email protected]>
I tried the idea above, i.e. creating an I normally use So my question is this: is there a way to tell Edit: the
|
Changed the last line of the
This seems to have stopped the "looping". |
I've added this to a "template" repo that I use as a starting point when starting new documentation projects based on mdbook. The |
Oh ... and in the interest of avoiding any confusion, "kg4zow" is my personal account, "jms1voalte" is my work account. Same guy, different desk. |
Some books on the Rust bookshelf show the rust version and exact commit from which the documents were built.
For example, see the bottom-right corner of these pages:
What's the best way to do that in mdbook land? Is it possible at all to do so automatically?
If we need to build something for it, how about adding a version/commit signature to the bottom of the left-hand sidebar?
The text was updated successfully, but these errors were encountered: