diff --git a/build-docs.just b/build-docs.just index 8c54d046d..a15d00fb2 100644 --- a/build-docs.just +++ b/build-docs.just @@ -42,9 +42,12 @@ header: @echo Generating theme/header.hbs @uv run docs/generate_header.py -# Build documentation for previous releases -old: header - @# Clean output dir - @rm -rf book/release +# Move the dev docs to the same level as the old docs +move-dev: header book + @echo Moving dev docs to /dev + @uv run docs/move_dev_docs.py +# Build documentation for previous releases +old: move-dev + @echo Building old versions of docs @uv run docs/build_old_docs.py diff --git a/docs/build_old_docs.py b/docs/build_old_docs.py index 6ad3f0cad..8f302a1ac 100755 --- a/docs/build_old_docs.py +++ b/docs/build_old_docs.py @@ -85,7 +85,7 @@ def build_docs_for_release(release: str, repo_path: Path, outdir: Path) -> None: def build_old_docs() -> None: """Build documentation for previous releases.""" - outdir = REPO_ROOT / "book" / "release" + outdir = REPO_ROOT / "book" outdir.mkdir(parents=True, exist_ok=True) # Clone this repo to a temporary directory diff --git a/docs/move_dev_docs.py b/docs/move_dev_docs.py new file mode 100755 index 000000000..19a886e11 --- /dev/null +++ b/docs/move_dev_docs.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 +# +# A script to move the development docs into a /dev directory + +import shutil +from pathlib import Path +from tempfile import TemporaryDirectory + +from release import get_releases + +DOCS_SITE_ROOT = "https://energysystemsmodellinglab.github.io/MUSE2" +REPO_ROOT = Path(__file__).parent.parent.absolute() + + +def move_to_dev() -> None: + """Build documentation for previous releases.""" + bookdir = REPO_ROOT / "book" + outdir = REPO_ROOT / "book" / "dev" + + with TemporaryDirectory() as tmpdir: + # Move book to temporary directory + shutil.move(bookdir, tmpdir) + shutil.move(Path(tmpdir) / "book", outdir) + + # Redirect to stable (most recent) version of docs + with (bookdir / "index.html").open("w", encoding="utf-8") as f: + f.write(f"""
+ +""") + + +if __name__ == "__main__": + move_to_dev() diff --git a/docs/release_notes/v2.1.0.md b/docs/release_notes/v2.1.0.md index 9ddec4242..0f38997dc 100644 --- a/docs/release_notes/v2.1.0.md +++ b/docs/release_notes/v2.1.0.md @@ -134,14 +134,14 @@ previous versions of MUSE2. [#1205]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1205 -[`demand.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#demandcsv -[`processes.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#processescsv -[`process_flows.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#process_flowscsv -[`process_availabilities.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#process_availabilitiescsv -[`process_parameters.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#process_parameterscsv -[`process_investment_constraints.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#process_investment_constraintscsv -[`commodities.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#commoditiescsv -[`commodity_levies.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#commodity_leviescsv -[`model.toml`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#model-parameters-modeltoml -[`assets.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/input_files.html#assetscsv -[`settings.toml`]: https://energysystemsmodellinglab.github.io/MUSE2/release/v2.1.0/file_formats/program_settings.html +[`demand.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#demandcsv +[`processes.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#processescsv +[`process_flows.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#process_flowscsv +[`process_availabilities.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#process_availabilitiescsv +[`process_parameters.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#process_parameterscsv +[`process_investment_constraints.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#process_investment_constraintscsv +[`commodities.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#commoditiescsv +[`commodity_levies.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#commodity_leviescsv +[`model.toml`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#model-parameters-modeltoml +[`assets.csv`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/input_files.html#assetscsv +[`settings.toml`]: https://energysystemsmodellinglab.github.io/MUSE2/v2.1.0/file_formats/program_settings.html diff --git a/docs/templates/header.hbs.jinja b/docs/templates/header.hbs.jinja index 889ca33db..6e90802bc 100644 --- a/docs/templates/header.hbs.jinja +++ b/docs/templates/header.hbs.jinja @@ -90,30 +90,20 @@ var labelText = document.getElementById("version-label-text"); var list = document.getElementById("version-list"); - var versionMatch = /\/release\/(v[\d.]+)\//.exec(path); + var versionMatch = /\/(v[\d.]+)\//.exec(path); var isDev = !versionMatch; - var currentVersion = isDev ? "development" : versionMatch[1]; + var currentVersion = isDev ? "dev" : versionMatch[1]; var isStable = false; // Build version list var pathToRoot = "{% raw %}{{path_to_root}}{% endraw %}"; var versions = [ - { label: "development", stable: false }, + { label: "dev", stable: false }, {%- for release in releases %} { label: "{{ release.label }}", stable: {{ release.stable|lower }} }, {%- endfor %} ]; - function hrefFor(label) { - if (isDev) { - if (label === "development") return pathToRoot; - return pathToRoot + "release/" + label + "/index.html"; - } - // Old versioned docs (e.g. /release/v2.0.0/) - if (label === "development") return pathToRoot + "../../index.html"; - return pathToRoot + "../" + label + "/index.html"; - } - versions.forEach(function (v) { var li = document.createElement("li"); @@ -130,7 +120,7 @@ li.appendChild(strong); } else { var a = document.createElement("a"); - a.href = hrefFor(v.label); + a.href = pathToRoot + "../" + v.label + "/index.html"; a.textContent = versionLabel; li.appendChild(a); } diff --git a/src/cli.rs b/src/cli.rs index 1c85cf56f..84f7b8a6a 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -21,7 +21,7 @@ use settings::SettingsSubcommands; version, about, after_help = concat!( - "For more detailed documentation on this version of MUSE2, see: https://energysystemsmodellinglab.github.io/MUSE2/release/v", + "For more detailed documentation on this version of MUSE2, see: https://energysystemsmodellinglab.github.io/MUSE2/v", env!("CARGO_PKG_VERSION"), "/" ) diff --git a/tests/cli.rs b/tests/cli.rs index 4cd5ee69a..7087e03ee 100644 --- a/tests/cli.rs +++ b/tests/cli.rs @@ -17,7 +17,7 @@ fn check_help_command() { assert!( get_muse2_stdout(&["help"]).contains( format!( - "https://energysystemsmodellinglab.github.io/MUSE2/release/v{}/", + "https://energysystemsmodellinglab.github.io/MUSE2/v{}/", env!("CARGO_PKG_VERSION") ) .as_str()