Skip to content

Commit 92bd503

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 6864aa8 commit 92bd503

22 files changed

+514
-791
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
@@ -182,14 +182,10 @@ AM_CFLAGS += $(onig_CFLAGS)
182182

183183
### Packaging
184184

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

192-
DOC_FILES = docs/content docs/public docs/templates docs/site.yml \
188+
DOC_FILES = docs/content docs/public docs/templates \
193189
docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \
194190
docs/build_manpage.py docs/README.md jq.1.prebuilt
195191

docs/Pipfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ verify_ssl = true
99
jinja2 = "*"
1010
pyyaml = "*"
1111
markdown = "*"
12-
lxml = "*"
12+
lxml = "*"

docs/Pipfile.lock

Lines changed: 143 additions & 149 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/build_manpage.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
# Prevent our markdown parser from trying to help by interpreting things in angle brackets as HTML tags.
1313
class EscapeHtml(Extension):
1414

15-
def extendMarkdown(self, md, md_globals):
16-
del md.preprocessors['html_block']
17-
del md.inlinePatterns['html']
15+
def extendMarkdown(self, md):
16+
md.preprocessors.deregister('html_block')
17+
md.inlinePatterns.deregister('html')
1818

1919

2020
class RoffWalker(object):

docs/build_website.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
#!/usr/bin/env python3
22
import glob
33
import itertools
4-
from jinja2 import Environment, FileSystemLoader, Markup, select_autoescape, contextfunction
4+
from jinja2 import Environment, FileSystemLoader, select_autoescape, pass_context
55
from markdown import markdown
6+
from markupsafe import Markup
67
import os
78
import os.path
89
import re
@@ -20,40 +21,44 @@ def load_yml_file(fn):
2021
return yaml.safe_load(f)
2122

2223

24+
env.globals['url'] = 'https://jqlang.github.io/jq'
25+
env.globals['root'] = '/jq'
26+
2327
env.filters['search_id'] = lambda input: input.replace(r'`', '')
24-
env.filters['section_id'] = lambda input: re.sub(r"[^a-zA-Z0-9_]", '', input)
25-
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()
2638
env.filters['markdownify'] = lambda input: Markup(markdown(input))
27-
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))
2840

29-
env.globals['unique_id'] = contextfunction(
41+
env.globals['unique_id'] = pass_context(
3042
lambda ctx: str(next(ctx['unique_ctr'])))
3143

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

37-
def generate_file(env, fname='content/1.tutorial/default.yml'):
45+
def generate_file(env, fname):
3846
path, base = os.path.split(fname)
3947
path = os.path.relpath(path, 'content')
4048
if path == '.':
4149
path = ''
42-
slug = 'index'
4350
permalink = ''
4451
else:
45-
slug = os.path.basename(path)
4652
permalink = path + '/'
4753

4854
output_dir = os.path.join('output', path)
4955
output_path = os.path.join(output_dir, 'index.html')
5056

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

5359
ctx = load_yml_file(fname)
5460
ctx.update(unique_ctr=itertools.count(1),
5561
permalink=permalink,
56-
slug=slug,
5762
navitem=path)
5863
os.makedirs(output_dir, exist_ok=True)
5964
env.get_template(template_name).stream(ctx).dump(output_path,

docs/content/download/default.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ body:
191191
jq's documentation is compiled into static HTML using Python.
192192
To build the docs, run `pipenv run python3 build_website.py` from
193193
the docs/ subdirectory. To serve them locally, you can run
194-
`python3 -m SimpleHTTPServer`. You'll need a few Python dependencies,
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)