Skip to content

Commit

Permalink
Merge branch 'mike-docs' into mike-docs-1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
igordejanovic committed Sep 8, 2018
2 parents a2339df + 6205e26 commit 3bbb554
Show file tree
Hide file tree
Showing 3 changed files with 98 additions and 27 deletions.
5 changes: 5 additions & 0 deletions docs/css/version-select.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#version-selector {
display: block;
margin: -10px auto 0.809em;
padding: 2px;
}
64 changes: 64 additions & 0 deletions docs/js/version-select.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
window.addEventListener("DOMContentLoaded", function() {
function normalizePath(path) {
var normalized = [];
path.split("/").forEach(function(bit, i) {
if (bit === "." || (bit === "" && i !== 0)) {
return;
} else if (bit === "..") {
if (normalized.length === 1 && normalized[0] === "") {
// We must be trying to .. past the root!
throw new Error("invalid path");
} else if (normalized.length === 0 ||
normalized[normalized.length - 1] === "..") {
normalized.push("..");
} else {
normalized.pop();
}
} else {
normalized.push(bit);
}
});
return normalized.join("/");
}

// `base_url` comes from the base.html template for this theme.
var REL_BASE_URL = base_url;
var ABS_BASE_URL = normalizePath(window.location.pathname + "/" +
REL_BASE_URL);
var CURRENT_VERSION = ABS_BASE_URL.split("/").pop();

function makeSelect(options, selected) {
var select = document.createElement("select");

options.forEach(function(i) {
var option = new Option(i.text, i.value, undefined,
i.value === selected);
select.add(option);
});

return select;
}

var xhr = new XMLHttpRequest();
xhr.open("GET", REL_BASE_URL + "/../versions.json");
xhr.onload = function() {
var versions = JSON.parse(this.responseText);

var realVersion = versions.find(function(i) {
return i.version === CURRENT_VERSION ||
i.aliases.includes(CURRENT_VERSION);
}).version;

var select = makeSelect(versions.map(function(i) {
return {text: i.title, value: i.version};
}), realVersion);
select.id = "version-selector";
select.addEventListener("change", function(event) {
window.location.href = REL_BASE_URL + "/../" + this.value;
});

var title = document.querySelector("div.wy-side-nav-search");
title.insertBefore(select, title.querySelector(".icon-home").nextSibling);
};
xhr.send();
});
56 changes: 29 additions & 27 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,43 @@ site_description: A meta-language for building Domain-Specific Languages (DSLs)
site_author: Igor Dejanović

repo_url: https://github.com/igordejanovic/textX
google_analytics: ['UA-68681917-1', 'igordejanovic.net']
google_analytics: [UA-68681917-1, igordejanovic.net]
theme: readthedocs
extra_css: ['style.css']
extra_css: [style.css, css/version-select.css]

pages:
nav:
- Home: index.md
- User Guide:
- Grammar: grammar.md
- Meta-model: metamodel.md
- Model: model.md
- Scoping: scoping.md
- Multi meta-model: multimetamodel.md
- Parser configuration: parser_config.md
- Visualization: visualization.md
- Error handling: error_handling.md
- Debugging: debugging.md
- textx command: textx_command.md
- Grammar: grammar.md
- Meta-model: metamodel.md
- Model: model.md
- Scoping: scoping.md
- Multi meta-model: multimetamodel.md
- Parser configuration: parser_config.md
- Visualization: visualization.md
- Error handling: error_handling.md
- Debugging: debugging.md
- textx command: textx_command.md
- Tutorials:
- Hello World: tutorials/hello_world.md
- Robot: tutorials/robot.md
- Entity: tutorials/entity.md
- State Machine: tutorials/state_machine.md
- Toy language compiler: tutorials/toylanguage.md
- Hello World: tutorials/hello_world.md
- Robot: tutorials/robot.md
- Entity: tutorials/entity.md
- State Machine: tutorials/state_machine.md
- Toy language compiler: tutorials/toylanguage.md
- About:
- Comparison: about/comparison.md
- Discuss: about/discuss.md
- Contributing: about/contributing.md
- License: about/license.md
- Comparison: about/comparison.md
- Discuss: about/discuss.md
- Contributing: about/contributing.md
- License: about/license.md
- What's new:
- Release 1.5: whatsnew/release_1_5.md
- Release 1.5: whatsnew/release_1_5.md

markdown_extensions:
- admonition:
- toc:
permalink: True
- admonition:
- toc:
permalink: true

copyright: Copyright &copy; 2016 <a href="http://igordejanovic.net/">Igor Dejanović</a>.
copyright: Copyright &copy; <a href="http://igordejanovic.net/">Igor Dejanović</a>.

extra_javascript:
- js/version-select.js

0 comments on commit 3bbb554

Please sign in to comment.