Skip to content

Commit fa6a2ff

Browse files
authored
website: remove unused root path on building website (jqlang#3248)
We no longer use the `--root` option of `build_website.py` since we have moved to jqlang.org (from jqlang.github.io/jq where the root was `/jq`). We don't need the option on local development either since `http.server` has the `-d` option to specify the directory to serve from.
1 parent e33578a commit fa6a2ff

File tree

7 files changed

+20
-28
lines changed

7 files changed

+20
-28
lines changed

docs/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,5 @@ the `Makefile` will be able to generate the jq manpage. You can just run
2121
`make jq.1` to build the manpage manually, and `make tests/man.test` to
2222
update the manual tests.
2323

24-
To build the website, run `pipenv run python3 build_website.py --root /output`
25-
in the `docs/` directory. To serve them locally, you can run
26-
`python3 -m http.server`.
24+
To build the website, run `pipenv run python3 build_website.py` in the `docs/` directory.
25+
To serve them locally, you can run `python3 -m http.server -d output`.

docs/build_website.py

-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#!/usr/bin/env python3
2-
import argparse
32
import glob
43
import itertools
54
from jinja2 import Environment, FileSystemLoader, select_autoescape, pass_context
@@ -11,10 +10,6 @@
1110
import shutil
1211
import yaml
1312

14-
parser = argparse.ArgumentParser()
15-
parser.add_argument('--root', default='')
16-
args = parser.parse_args()
17-
1813
env = Environment(
1914
loader=FileSystemLoader('templates'),
2015
autoescape=select_autoescape(['html.j2']),
@@ -27,8 +22,6 @@ def load_yml_file(fn):
2722

2823

2924
env.globals['url'] = 'https://jqlang.org'
30-
env.globals['root'] = args.root
31-
3225
env.filters['search_id'] = lambda input: input.replace(r'`', '')
3326
env.filters['section_id'] = lambda input: re.sub(
3427
r'[^-a-zA-Z0-9_]', '', input.replace(' ', '-')).lower()

docs/content/download/default.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ body:
239239
#### Building the documentation
240240
241241
jq's documentation is compiled into static HTML using Python.
242-
To build the docs, run `pipenv run python3 build_website.py --root /output`
242+
To build the docs, run `pipenv run python3 build_website.py`
243243
in the `docs/` directory. To serve them locally, you can run
244-
`python3 -m http.server`. You'll need a few Python dependencies,
244+
`python3 -m http.server -d output`. You'll need a few Python dependencies,
245245
which can be installed by following the instructions in `docs/README.md`.
246246
247247
The man page is built by `make jq.1`, or just `make`, also from

docs/templates/index.html.j2

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<main id="main" class="container-lg">
99
<div class="row">
1010
<div class="col-md-6 text-center p-3">
11-
<h1><img src="{{ root }}/jq.svg" class="img-fluid" alt="jq" width="400" height="220"></h1>
11+
<h1><img src="/jq.svg" class="img-fluid" alt="jq" width="400" height="220"></h1>
1212
</div>
1313
<div class="col-md-6 d-flex flex-column justify-content-center text-center align-items-center">
1414
<h2 class="px-1" style="width:16em">{{ blurb }}</h2>
@@ -23,7 +23,7 @@
2323
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-macos-amd64" aria-label="Link to download executable: macOS (AMD64)"><span class="bi bi-download me-2" aria-hidden="true"></span>macOS (AMD64)</a></li>
2424
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-macos-arm64" aria-label="Link to download executable: macOS (ARM64)"><span class="bi bi-download me-2" aria-hidden="true"></span>macOS (ARM64)</a></li>
2525
<li><a class="dropdown-item" href="https://github.com/jqlang/jq/releases/download/jq-1.7.1/jq-windows-amd64.exe" aria-label="Link to download executable: Windows (AMD64)"><span class="bi bi-download me-2" aria-hidden="true"></span>Windows (AMD64)</a></li>
26-
<li><a class="dropdown-item" href="{{ root }}/download/">Other platforms, older versions, and source</a></li>
26+
<li><a class="dropdown-item" href="/download/">Other platforms, older versions, and source</a></li>
2727
</ul>
2828
<a class="btn btn-primary text-nowrap" href="https://jqplay.org" target="_blank" rel="noopener">
2929
Try online at jqplay.org!<span class="bi bi-box-arrow-up-right ms-1" aria-hidden="true"></span>

docs/templates/manual.html.j2

+7-7
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,12 @@
3636
<p>
3737
<em>
3838
For other versions, see
39-
<a href="{{ root }}/manual/v1.7/">1.7</a>,
40-
<a href="{{ root }}/manual/v1.6/">1.6</a>,
41-
<a href="{{ root }}/manual/v1.5/">1.5</a>,
42-
<a href="{{ root }}/manual/v1.4/">1.4</a>,
43-
<a href="{{ root }}/manual/v1.3/">1.3</a> or
44-
<a href="{{ root }}/manual/dev/">development version</a>.
39+
<a href="/manual/v1.7/">1.7</a>,
40+
<a href="/manual/v1.6/">1.6</a>,
41+
<a href="/manual/v1.5/">1.5</a>,
42+
<a href="/manual/v1.4/">1.4</a>,
43+
<a href="/manual/v1.3/">1.3</a> or
44+
<a href="/manual/dev/">development version</a>.
4545
</em>
4646
</p>
4747
{{ body | markdownify }}
@@ -115,6 +115,6 @@
115115
{%- endfor %}
116116
}
117117
</script>
118-
<script src="{{ root }}/js/manual-search.js"></script>
118+
<script src="/js/manual-search.js"></script>
119119
</body>
120120
</html>

docs/templates/shared/_head.html.j2

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@
55
<meta property="og:title" content="{{ headline }}">
66
<meta property="og:description" content="jq is a lightweight and flexible command-line JSON processor">
77
<meta property="og:type" content="website">
8-
<meta property="og:image" content="{{ url }}{{ root }}/icon.png">
8+
<meta property="og:image" content="{{ url }}/icon.png">
99
<meta property="og:url" content="{{ url }}/{{ permalink }}">
10-
<link rel="icon" href="{{ root }}/icon.svg" type="image/svg+xml">
11-
<link rel="apple-touch-icon" href="{{ root }}/icon.png" type="image/png">
10+
<link rel="icon" href="/icon.svg" type="image/svg+xml">
11+
<link rel="apple-touch-icon" href="/icon.png" type="image/png">
1212
<link rel="canonical" href="{{ url }}/{{ permalink }}">
1313
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/cosmo/bootstrap.min.css"
1414
integrity="sha384-dulfW0vmzZ638jigSgZXvDxMmd70GCnIv6oa+riKq6Kk4E0MKf7qmBfwP02wltv5" crossorigin="anonymous">
1515
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css"
1616
integrity="sha384-Ay26V7L8bsJTsX9Sxclnvsn+hkdiwRnrjZJXqKmkIDobPgIIWBOVguEcQQLDuhfN" crossorigin="anonymous">
17-
<link rel="stylesheet" href="{{ root }}/css/style.css" type="text/css">
17+
<link rel="stylesheet" href="/css/style.css" type="text/css">
1818
<script>
1919
(function() {
2020
function setTheme(mediaQuery) {

docs/templates/shared/_navbar.html.j2

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010
aria-controls="navbar-collapse" aria-expanded="false" aria-label="Toggle page navigation">
1111
<span class="navbar-toggler-icon"></span>
1212
</button>
13-
<a class="navbar-brand" href="{{ root }}/" aria-label="Top page"><img src="{{ root }}/jq.svg" alt="jq logo" style="height:1.5rem"></a>
13+
<a class="navbar-brand" href="/" aria-label="Top page"><img src="/jq.svg" alt="jq logo" style="height:1.5rem"></a>
1414
<div id="navbar-collapse" class="offcanvas offcanvas-start navbar-collapse w-auto" aria-labelledby="navbar-title">
1515
<div class="offcanvas-header">
1616
<h3 id="navbar-title" class="me-3">jq</h3>
1717
<button type="button" class="d-md-none btn-close" data-bs-dismiss="offcanvas" aria-label="Close page navigation"></button>
1818
</div>
1919
<ul class="offcanvas-body navbar-nav me-auto text-nowrap">
20-
<li class="nav-item d-md-none"><a class="nav-link{% if not navitem %} active{% endif %}"{% if not navitem %} aria-current="page"{% endif %} href="{{ root }}/">Top page</a></li>
20+
<li class="nav-item d-md-none"><a class="nav-link{% if not navitem %} active{% endif %}"{% if not navitem %} aria-current="page"{% endif %} href="/">Top page</a></li>
2121
{%- for item in ['tutorial', 'download', 'manual'] %}
22-
<li class="nav-item"><a class="nav-link{% if item == navitem %} active{% endif %}"{% if item == navitem %} aria-current="page"{% endif %} href="{{ root }}/{{ item }}/">{{ item | capitalize }}</a></li>
22+
<li class="nav-item"><a class="nav-link{% if item == navitem %} active{% endif %}"{% if item == navitem %} aria-current="page"{% endif %} href="/{{ item }}/">{{ item | capitalize }}</a></li>
2323
{%- endfor %}
2424
<li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq" target="_blank" rel="noopener">GitHub</a></li>
2525
<li class="nav-item"><a class="nav-link" href="https://github.com/jqlang/jq/issues" target="_blank" rel="noopener">Issues</a></li>

0 commit comments

Comments
 (0)