Skip to content

Commit 46b7b1b

Browse files
authored
Merge pull request #206 from stan-dev/also-index-docs
Merge docs search.json into top-level search.json
2 parents d3487a7 + d0984dd commit 46b7b1b

3 files changed

Lines changed: 46 additions & 5 deletions

File tree

.github/workflows/build.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
- master
77
workflow_dispatch:
88

9-
109
concurrency:
1110
group: production
1211
cancel-in-progress: true
@@ -29,19 +28,19 @@ jobs:
2928
- name: Set up Quarto
3029
uses: quarto-dev/quarto-actions/setup@v2
3130
with:
31+
# note: when updating, make sure merge_docs_search.py still works
3232
version: 1.6.39
3333

3434
- name: Render with Quarto
3535
run: |
36-
mkdir -p site
3736
quarto render --to html
3837
3938
- name: Setup Pages
4039
uses: actions/configure-pages@v4
4140
- name: Upload artifact
4241
uses: actions/upload-pages-artifact@v3
4342
with:
44-
path: './_website'
43+
path: "./_website"
4544
- name: Deploy to GitHub Pages
4645
id: deployment
4746
uses: actions/deploy-pages@v4

_quarto.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@ project:
22
title: "Stan"
33
type: website
44
output-dir: _website
5-
post-render: quarto-config/generate_redirects.py redirects.txt --output_dir=_website
6-
# TODO merge search.json with docs search.json
5+
post-render:
6+
- quarto-config/generate_redirects.py redirects.txt --output_dir=_website
7+
- ./merge_docs_search.py --output_dir=_website
78
render:
89
- "index.qmd"
910
- "404.qmd"

merge_docs_search.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
"""
2+
Make it so that the top-level searching for the website includes the Stan
3+
documentation stubs as well
4+
"""
5+
6+
import pathlib
7+
import argparse
8+
import json
9+
10+
import requests
11+
12+
13+
DOCS_JSON_URL = "https://mc-stan.org/docs/search.json"
14+
15+
arguments = argparse.ArgumentParser()
16+
arguments.add_argument(
17+
"--output_dir", type=pathlib.Path, default=pathlib.Path(__file__).parent
18+
)
19+
20+
args = arguments.parse_args()
21+
22+
out = args.output_dir
23+
24+
search = out / "search.json"
25+
26+
search_data = json.loads(search.read_text())
27+
28+
docs_search = json.loads(requests.get(DOCS_JSON_URL).text)
29+
30+
for item in docs_search:
31+
# need to add the /docs/ prefix to the objectID and href
32+
objectID = item["objectID"]
33+
href = item["href"]
34+
item |= {
35+
"objectID": f"docs/{objectID}",
36+
"href": f"docs/{href}",
37+
}
38+
39+
search_data.append(item)
40+
41+
search.write_text(json.dumps(search_data, indent=2))

0 commit comments

Comments
 (0)