File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66 - master
77 workflow_dispatch :
88
9-
109concurrency :
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
Original file line number Diff line number Diff line change 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"
Original file line number Diff line number Diff line change 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 ))
You can’t perform that action at this time.
0 commit comments