-
Notifications
You must be signed in to change notification settings - Fork 3
Move dev docs #1366
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
base: main
Are you sure you want to change the base?
Move dev docs #1366
Changes from all commits
2b5fb81
ecde674
a164d87
7cfc286
daff65e
755d0f4
07a3df8
88179b3
fc73bd5
285b86f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #!/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 | ||
|
|
||
| REPO_ROOT = Path(__file__).parent.parent.absolute() | ||
|
|
||
|
|
||
| def move_to_dev() -> None: | ||
| """Move the built documentation output (`book/`) into `book/dev/`.""" | ||
| 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) | ||
|
|
||
|
Comment on lines
+16
to
+23
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds correct... but the code works as is, so I'm not inclined to change it |
||
| # 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=./{get_releases()[0]}/index.html" | ||
| /> | ||
| </head>""") | ||
|
Comment on lines
+24
to
+31
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is an edge-case that I don't think we need to worry about |
||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| move_to_dev() | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that we now exclude the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These were kept as absolute links in #1344 because the links might break in future versions of the documentation, so it made sense to keep these link to the version of the docs that these release notes are referring to. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This regex doesn't quite make sense to me. I think the
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, I don't understand regex, and this was co-pilot. I believe it's looking for a version string like "v2.1.0" so I interpreted the |
||
| 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); | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.