Skip to content

Commit fa80e46

Browse files
committed
Redesign website
* Bump up Bootstrap to v5.3.0, Bootstrap Icon to v1.10.5. * Use autoComplete.js to drop dependency on jQuery, typeahead.js. * Support dark mode. * New svg logo and icon with responsive color mode support. * Improve section ids to make them easy to link in Markdown. * Various markup cleanups and accessibility improvements.
1 parent 481167c commit fa80e46

File tree

19 files changed

+365
-637
lines changed

19 files changed

+365
-637
lines changed

.github/workflows/website.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
- name: Setup Python
2121
uses: actions/setup-python@v4
2222
with:
23-
python-version: '3.10'
23+
python-version: '3.11'
2424
cache: pipenv
2525
- name: Install pipenv
2626
run: pip install pipenv

Makefile.am

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -184,14 +184,10 @@ AM_CFLAGS += $(onig_CFLAGS)
184184

185185
### Packaging
186186

187-
docs/site.yml: configure.ac
188-
sed 's/^jq_version: .*/jq_version: "$(VERSION)"/' $@ > $@.new
189-
mv $@.new $@
190-
191187
install-binaries: $(BUILT_SOURCES)
192188
$(MAKE) $(AM_MAKEFLAGS) install-exec
193189

194-
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
190+
DOC_FILES = docs/content docs/public docs/templates \
195191
docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \
196192
docs/build_manpage.py docs/README.md jq.1.prebuilt
197193

docs/build_website.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,40 +21,44 @@ def load_yml_file(fn):
2121
return yaml.safe_load(f)
2222

2323

24+
env.globals['url'] = 'https://jqlang.github.io/jq'
25+
env.globals['root'] = '/jq'
26+
2427
env.filters['search_id'] = lambda input: input.replace(r'`', '')
25-
env.filters['section_id'] = lambda input: re.sub(r"[^a-zA-Z0-9_]", '', input)
26-
env.filters['entry_id'] = lambda input: re.sub(r"[ `]", '', input)
28+
env.filters['section_id'] = lambda input: re.sub(
29+
r'[^-a-zA-Z0-9_]', '', input.replace(' ', '-')).lower()
30+
env.filters['entry_id'] = lambda input: re.sub(
31+
r'^(split|first-last-nth)$',
32+
r'\1' + ('-1' if ';' not in input else '-2'), # avoid id conflict
33+
re.sub(
34+
r'\b([^-]+)(?:-\1)+\b',
35+
r'\1', # e.g. range-range-range -> range
36+
re.sub(r' ?/ ?|,? ', '-', re.sub(r'`|: .*|\(.*?\)', '', input)))
37+
).lower()
2738
env.filters['markdownify'] = lambda input: Markup(markdown(input))
28-
env.filters['no_paragraph'] = lambda input: Markup(re.sub(r"</?p>", '', input))
39+
env.filters['no_paragraph'] = lambda input: Markup(re.sub(r'</?p>', '', input))
2940

3041
env.globals['unique_id'] = pass_context(
3142
lambda ctx: str(next(ctx['unique_ctr'])))
3243

33-
env.globals.update(load_yml_file('site.yml'))
34-
35-
env.globals['navigation'] = ['tutorial', 'download', 'manual']
36-
3744

38-
def generate_file(env, fname='content/1.tutorial/default.yml'):
45+
def generate_file(env, fname):
3946
path, base = os.path.split(fname)
4047
path = os.path.relpath(path, 'content')
4148
if path == '.':
4249
path = ''
43-
slug = 'index'
4450
permalink = ''
4551
else:
46-
slug = os.path.basename(path)
4752
permalink = path + '/'
4853

4954
output_dir = os.path.join('output', path)
5055
output_path = os.path.join(output_dir, 'index.html')
5156

52-
template_name = re.sub(r".yml$", '.html.j2', base)
57+
template_name = re.sub(r'.yml$', '.html.j2', base)
5358

5459
ctx = load_yml_file(fname)
5560
ctx.update(unique_ctr=itertools.count(1),
5661
permalink=permalink,
57-
slug=slug,
5862
navitem=path)
5963
os.makedirs(output_dir, exist_ok=True)
6064
env.get_template(template_name).stream(ctx).dump(output_path,

docs/content/download/default.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ body:
190190
191191
jq's documentation is compiled into static HTML using Python.
192192
To build the docs, run `pipenv run python3 build_website.py` from
193-
the docs/ subdirectory. To serve them locally, you can run
194-
`python3 -m SimpleHTTPServer`. You'll need a few Python dependencies,
193+
the `docs/` subdirectory. To serve them locally, you can run
194+
`python3 -m http.server`. You'll need a few Python dependencies,
195195
which can be installed by following the instructions in `docs/README.md`.
196196
197197
The man page is built by `make jq.1`, or just `make`, also from

docs/public/css/base.css

Lines changed: 0 additions & 173 deletions
This file was deleted.

0 commit comments

Comments
 (0)