Skip to content

Commit 1012bd4

Browse files
docs: Parameterize git references in links. (#1712)
1 parent e2f1754 commit 1012bd4

7 files changed

Lines changed: 40 additions & 17 deletions

File tree

docs/conf/conf.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
from datetime import date
22

3+
from sphinx.application import Sphinx
4+
5+
# Constants
6+
CLP_GIT_REF = "main"
7+
8+
39
# -- Project information -------------------------------------------------------
410
# https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information
511

@@ -79,7 +85,7 @@
7985
"show_prev_next": False,
8086
"switcher": {
8187
"json_url": "https://docs.yscope.com/_static/clp-versions.json",
82-
"version_match": "main",
88+
"version_match": CLP_GIT_REF,
8389
},
8490
"use_edit_page_button": True,
8591
}
@@ -90,7 +96,7 @@
9096
html_context = {
9197
"github_user": "y-scope",
9298
"github_repo": "clp",
93-
"github_version": "main",
99+
"github_version": CLP_GIT_REF,
94100
"doc_path": "docs/src",
95101
}
96102

@@ -99,5 +105,22 @@
99105
# https://pydata-sphinx-theme.readthedocs.io/en/stable/user_guide/static_assets.html
100106

101107

102-
def setup(app):
108+
def setup(app: Sphinx) -> None:
103109
app.add_css_file("custom.css")
110+
111+
app.connect("source-read", _replace_variable_placeholders)
112+
113+
114+
def _replace_variable_placeholders(_app: Sphinx, _docname: str, content: list[str]) -> None:
115+
"""
116+
Replaces each variable placeholder in the docs with the relevant value.
117+
118+
:param _app:
119+
:param _docname:
120+
:param content: The content of the doc in a list with a single element.
121+
"""
122+
placeholder_to_value = {
123+
"DOCS_VAR_CLP_GIT_REF": CLP_GIT_REF,
124+
}
125+
for placeholder, value in placeholder_to_value.items():
126+
content[0] = content[0].replace(placeholder, value)

docs/src/dev-docs/components-core/centos-stream-9-deps-install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ without using a packager. So if you ever need to uninstall them, you will need t
2121
components/core/tools/scripts/lib_install/centos-stream-9/install-all.sh
2222
```
2323

24-
[src-install-script]: https://github.com/y-scope/clp/blob/main/components/core/tools/scripts/lib_install/centos-stream-9/install-packages-from-source.sh
24+
[src-install-script]: https://github.com/y-scope/clp/blob/DOCS_VAR_CLP_GIT_REF/components/core/tools/scripts/lib_install/centos-stream-9/install-packages-from-source.sh

docs/src/dev-docs/components-core/macos-deps-install.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ To install all dependencies, run:
1616
components/core/tools/scripts/lib_install/macos/install-all.sh
1717
```
1818

19-
[gh-workflow]: https://github.com/y-scope/clp/blob/main/.github/workflows/clp-core-build-macos.yaml
19+
[gh-workflow]: https://github.com/y-scope/clp/blob/DOCS_VAR_CLP_GIT_REF/.github/workflows/clp-core-build-macos.yaml

docs/src/dev-docs/contributing-linting.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ To also apply any automatic fixes:
3333
task lint:fix
3434
```
3535

36-
[clp-artifact-build]: https://github.com/y-scope/clp/blob/main/.github/workflows/clp-artifact-build.yaml
37-
[clp-lint]: https://github.com/y-scope/clp/blob/main/.github/workflows/clp-lint.yaml
36+
[clp-artifact-build]: https://github.com/y-scope/clp/blob/DOCS_VAR_CLP_GIT_REF/.github/workflows/clp-artifact-build.yaml
37+
[clp-lint]: https://github.com/y-scope/clp/blob/DOCS_VAR_CLP_GIT_REF/.github/workflows/clp-lint.yaml
3838
[clp-issue-872]: https://github.com/y-scope/clp/issues/872
3939
[feature-req]: https://github.com/y-scope/clp/issues/new?assignees=&labels=enhancement&projects=&template=feature-request.yaml
4040
[Task]: https://taskfile.dev/

docs/src/dev-docs/design-project-structure.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ CLP is currently split across a few different components in the [components] dir
1111
* [package-template] contains the base directory structure and files of the CLP package.
1212
* [webui] contains the web interface for the CLP package.
1313

14-
[components]: https://github.com/y-scope/clp/tree/main/components
15-
[clp-mcp-server]: https://github.com/y-scope/clp/tree/main/components/clp-mcp-server
16-
[clp-package-utils]: https://github.com/y-scope/clp/tree/main/components/clp-package-utils
17-
[clp-py-utils]: https://github.com/y-scope/clp/tree/main/components/clp-py-utils
18-
[core]: https://github.com/y-scope/clp/tree/main/components/core
19-
[job-orchestration]: https://github.com/y-scope/clp/tree/main/components/job-orchestration
20-
[package-template]: https://github.com/y-scope/clp/tree/main/components/package-template
21-
[webui]: https://github.com/y-scope/clp/tree/main/components/webui
14+
[components]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components
15+
[clp-mcp-server]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/clp-mcp-server
16+
[clp-package-utils]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/clp-package-utils
17+
[clp-py-utils]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/clp-py-utils
18+
[core]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/core
19+
[job-orchestration]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/job-orchestration
20+
[package-template]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/package-template
21+
[webui]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/webui

docs/src/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ dev-docs/index
129129
[logback-appenders]: https://github.com/y-scope/logback-appenders
130130
[re2]: https://github.com/google/re2
131131
[uber-blog]: https://www.uber.com/en-US/blog/reducing-logging-cost-by-two-orders-of-magnitude-using-clp
132-
[webui]: https://github.com/y-scope/clp/blob/main/components/webui
132+
[webui]: https://github.com/y-scope/clp/tree/DOCS_VAR_CLP_GIT_REF/components/webui
133133
[yscope-community-discord]: https://discord.gg/7kZA2m5G87
134134
[yscope-community-slack]: https://communityinviter.com/apps/yscopecommunity/yscope-community
135135
[yscope-community-zulip]: https://yscope-clp.zulipchat.com

docs/src/user-docs/guides-using-the-api-server.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,4 +67,4 @@ following commands to submit a query to clp-json and stream the results.
6767
[OpenAPI]: https://swagger.io/specification/
6868
[release-choices]: ./quick-start/index.md#choosing-a-flavor
6969
[server-sent-events]: https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events
70-
[swagger-ui]: https://petstore.swagger.io/?url=https://docs.yscope.com/clp/main/_static/api-server-openapi.json
70+
[swagger-ui]: https://petstore.swagger.io/?url=https://docs.yscope.com/clp/DOCS_VAR_CLP_GIT_REF/_static/api-server-openapi.json

0 commit comments

Comments
 (0)