Skip to content
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

Manage multiple versions of documentation #770

Closed
bborysenko opened this issue Apr 25, 2018 · 4 comments
Closed

Manage multiple versions of documentation #770

bborysenko opened this issue Apr 25, 2018 · 4 comments

Comments

@bborysenko
Copy link

Will be great to have native support for jimporter/mike.

@squidfunk
Copy link
Owner

squidfunk commented Apr 26, 2018

This request came up quite a few times and there are some projects which try to solve it (e.g. this by one of the MkDocs creators) but in my opinion it's not a solved problem. jimporter/mike is a start but after some research I found it relies on JavaScript for version selection - not great. Material strictly follows the rules of progressive enhancement so that core functionality works without JavaScript. If JavaScript is not available, versions cannot be selected. Also adoption seems to be quite low. For this reason I have no intention of supporting the project.

@squidfunk
Copy link
Owner

squidfunk commented Apr 26, 2018

Also, you could implement versioning on your own using some shell scripts. You could build separate branches or tags of your git repository into separate folders and include a dropdown for version selection within the template. You could generate a Jinja template file which exports all generated versions as a macro. I used this technique to implement localization within Material, see:

{% macro t(key) %}{{ {
"language": "en",
"direction": "ltr",
"clipboard.copy": "Copy to clipboard",
"clipboard.copied": "Copied to clipboard",
"edit.link.title": "Edit this page",
"footer.previous": "Previous",
"footer.next": "Next",
"meta.comments": "Comments",
"meta.source": "Source",
"search.language": "en",
"search.pipeline.stopwords": true,
"search.pipeline.trimmer": true,
"search.placeholder": "Search",
"search.result.placeholder": "Type to start searching",
"search.result.none": "No matching documents",
"search.result.one": "1 matching document",
"search.result.other": "# matching documents",
"search.tokenizer": "[\s\-]+",
"skip.link.title": "Skip to content",
"source.link.title": "Go to repository",
"toc.title": "Table of contents"
}[key] }}{% endmacro %}

Within your macro you could export a list and then import the generated Jinja template and iterate that list. Importing works like this:

{% import "partials/language/en.html" as fallback %}

The fallback variable within this example can then be used as a variable within your template which you can iterate and generate a dropdown with the generated versions from. I hope that's helpful to you.

@squidfunk
Copy link
Owner

Closing as answered.

@jimporter
Copy link

For those who want to do this via mike, I've added support for the Material theme in jimporter/mike@c2b7a2d, which will be a part of mike 0.5 (to be released whenever MkDocs 1.1 is).

As a quick explanation to address the concerns raised above with how mike does things, I chose to use JS to build the version selector to meet a few goals: 1) old docs should link to newer versions; 2) once built, you should never have to rebuild docs for a version; 3) if the built docs are copied somewhere without versioning info, the version selector should go away; and 4) the solution should work on gh-pages (so no fancy server-side stuff). JS is the only way I could come up with that can do all that. Of course, not everyone cares about those goals, so perhaps it makes sense for mike to handle inserting the version selector for all the various MkDocs themes out there...

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

No branches or pull requests

3 participants