Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions build-docs.just
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion docs/build_old_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions docs/move_dev_docs.py
Original file line number Diff line number Diff line change
@@ -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"""<head>
<meta
http-equiv="Refresh"
content="0; URL={DOCS_SITE_ROOT}/{get_releases()[0]}/"
/>
</head>""")


if __name__ == "__main__":
move_to_dev()
22 changes: 11 additions & 11 deletions docs/release_notes/v2.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ previous versions of MUSE2.
[#1205]: https://github.com/EnergySystemsModellingLab/MUSE2/pull/1205

<!-- Use absolute links so they work when we paste into release notes box -->
[`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
18 changes: 4 additions & 14 deletions docs/templates/header.hbs.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
"/"
)
Expand Down
2 changes: 1 addition & 1 deletion tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Loading