Skip to content

Commit ac0c3a0

Browse files
authored
Merge pull request #30 from sphinx-notes/v2
sphinxnotes-snippet v2
2 parents 1c53109 + eb010e1 commit ac0c3a0

File tree

29 files changed

+763
-546
lines changed

29 files changed

+763
-546
lines changed

.cruft.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "https://github.com/sphinx-notes/template",
3-
"commit": "80a61fa9abcd9474d8cfbc36d0bf5d41f99c916c",
3+
"commit": "4736b672023e3bf4bc80d0d51850d7bc45ca1e12",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -14,7 +14,13 @@
1414
"github_repo": "snippet",
1515
"pypi_name": "sphinxnotes-snippet",
1616
"pypi_owner": "SilverRainZ",
17-
"_template": "https://github.com/sphinx-notes/template"
17+
"is_python_project": true,
18+
"python_version": "3.12",
19+
"is_sphinx_extension": true,
20+
"sphinx_version": "7.0",
21+
"development_status": "3 - Alpha",
22+
"_template": "https://github.com/sphinx-notes/template",
23+
"_commit": "4736b672023e3bf4bc80d0d51850d7bc45ca1e12"
1824
}
1925
},
2026
"directory": null

.github/workflows/pages.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ concurrency:
1313

1414
jobs:
1515
pages:
16-
runs-on: ubuntu-20.04
16+
runs-on: ubuntu-latest
1717
environment:
1818
name: github-pages
1919
url: ${{ steps.deployment.outputs.page_url }}

Makefile

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,30 @@ RM = rm -rf
99
GIT = git
1010
OPEN = xdg-open
1111

12-
# Build sphinx documentation.
1312
.PHONY: docs
1413
docs:
1514
$(MAKE) -C docs/
1615

17-
# View sphinx HTML documentation in browser.
1816
.PHONY: view
1917
view:
2018
$(OPEN) docs/_build/html/index.html
2119

2220
.PHONY: clean
2321
clean:
24-
$(MAKE) -C docs/ clean
25-
$(RM) dist/
22+
$(MAKE) -C docs/ clean; $(RM) dist/
2623

27-
.PHONY: clean
24+
.PHONY: fmt
2825
fmt:
29-
ruff format src/
26+
ruff format src/ && ruff check --fix src/
3027

31-
# Run unittest.
3228
.PHONY: test
3329
test:
3430
$(PY) -m unittest discover -s tests -v
3531

32+
################################################################################
33+
# Distribution Package
34+
################################################################################
35+
3636
# Build distribution package, for "install" or "upload".
3737
.PHONY: dist
3838
dist: pyproject.toml clean
@@ -54,33 +54,43 @@ install: dist
5454
upload: dist
5555
$(PY) -m twine upload --repository pypi $</*
5656

57-
# Same to the aboved "upload" target, but this publishs to PyPI test server
58-
# <https://test.pypi.org/>.
59-
.PHONY: upload-test
60-
upload-test: dist
61-
$(PY) -m twine upload --repository testpypi $</*
57+
################################################################################
58+
# Cookiecutter Incremental Updates
59+
################################################################################
6260

6361
# Keep up to date with the latest template.
64-
# See also https://github.com/sphinx-notes/cookiecutter.
65-
.PHONY: update-template
66-
update-template:
62+
# See https://github.com/sphinx-notes/cookiecutter.
63+
.PHONY: tmpl-update tmpl-update-done tmpl-apply-rej
64+
65+
tmpl-update:
6766
$(PY) -m cruft update
6867

69-
.PHONY: update-template-done
70-
update-template-done:
68+
tmpl-update-done:
7169
$(GIT) commit -m "chore: Update project template to sphinx-notes/cookiecutter@$(shell jq -r '.commit' .cruft.json | head -c8)"
7270

71+
tmpl-apply-rej:
72+
@for rej in $$(find . -name '*.rej'); do \
73+
echo "applying $$rej..."; \
74+
wiggle --replace $${rej%.rej} $$rej; \
75+
done
76+
7377
# Update project version.
74-
.PHONY: bump-version
78+
.PHONY: bump-version bump-version-done
79+
7580
bump-version:
7681
@echo -n "Please enter the version to bump: "
7782
@read version && $(PY) -m cruft update --variables-to-update "{ \"version\" : \"$$version\" }"
7883

79-
# EXTRA TARGETS START
84+
bump-version-done:
85+
VERSION=$(shell jq -r '.context.cookiecutter.version' .cruft.json); \
86+
$(GIT) commit -m "chore: Bump version to $$VERSION"; \
87+
$(GIT) tag $$VERSION
88+
89+
################################################################################
90+
# CUSTOM TARGETS
91+
################################################################################
8092

8193
# Usage: make cli args=--help
8294
.PHONY: cli
8395
cli:
8496
$(PY) ./utils/cli.py --config ./utils/conf.py $(args)
85-
86-
# EXTRA TARGETS END

README.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,14 @@ sphinxnotes-snippet
88
.. |docs| image:: https://img.shields.io/github/deployments/sphinx-notes/snippet/github-pages
99
:target: https://sphinx.silverrainz.me/snippet
1010
:alt: Documentation Status
11-
1211
.. |license| image:: https://img.shields.io/github/license/sphinx-notes/snippet
1312
:target: https://github.com/sphinx-notes/snippet/blob/master/LICENSE
1413
:alt: Open Source License
15-
1614
.. |pypi| image:: https://img.shields.io/pypi/v/sphinxnotes-snippet.svg
1715
:target: https://pypi.python.org/pypi/sphinxnotes-snippet
1816
:alt: PyPI Package
19-
2017
.. |download| image:: https://img.shields.io/pypi/dm/sphinxnotes-snippet
21-
:target: https://pypi.python.org/pypi/sphinxnotes-snippet
18+
:target: https://pypistats.org/packages/sphinxnotes-snippet
2219
:alt: PyPI Package Downloads
2320

2421
|docs| |license| |pypi| |download|

docs/_templates/confval.rst

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

docs/_templates/example.rst

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

docs/_templates/version.rst

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

docs/conf.py

Lines changed: 17 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
# list see the documentation:
88
# https://www.sphinx-doc.org/en/master/usage/configuration.html
99

10-
import os
11-
import sys
12-
1310
# -- Project information -----------------------------------------------------
1411

1512
project = 'sphinxnotes-snippet'
@@ -28,6 +25,7 @@
2825
'sphinx.ext.githubpages',
2926
'sphinx_design',
3027
'sphinx_copybutton',
28+
'sphinx_last_updated_by_git',
3129
]
3230

3331
# Add any paths that contain templates here, relative to this directory.
@@ -74,49 +72,6 @@
7472

7573
# -- Extensions -------------------------------------------------------------
7674

77-
#
78-
extensions.append('sphinxnotes.any')
79-
from sphinxnotes.any import Schema, Field as F
80-
#
81-
version_schema = Schema('version',
82-
name=F(unique=True, referenceable=True, required=True, form=F.Form.LINES),
83-
attrs={'date': F(referenceable=True)},
84-
content=F(form=F.Form.LINES),
85-
description_template=open('_templates/version.rst', 'r').read(),
86-
reference_template='🏷️{{ title }}',
87-
missing_reference_template='🏷️{{ title }}',
88-
ambiguous_reference_template='🏷️{{ title }}')
89-
confval_schema = Schema('confval',
90-
name=F(unique=True, referenceable=True, required=True, form=F.Form.LINES),
91-
attrs={
92-
'type': F(),
93-
'default': F(),
94-
'choice': F(form=F.Form.WORDS),
95-
'versionadded': F(),
96-
'versionchanged': F(form=F.Form.LINES),
97-
},
98-
content=F(),
99-
description_template=open('_templates/confval.rst', 'r').read(),
100-
reference_template='⚙️{{ title }}',
101-
missing_reference_template='⚙️{{ title }}',
102-
ambiguous_reference_template='⚙️{{ title }}')
103-
example_schema = Schema('example',
104-
name=F(referenceable=True),
105-
attrs={'style': F()},
106-
content=F(form=F.Form.LINES),
107-
description_template=open('_templates/example.rst', 'r').read(),
108-
reference_template='📝{{ title }}',
109-
missing_reference_template='📝{{ title }}',
110-
ambiguous_reference_template='📝{{ title }}')
111-
#
112-
any_schemas = [
113-
version_schema,
114-
confval_schema,
115-
example_schema,
116-
]
117-
primary_domain = 'any'
118-
#
119-
12075
extensions.append('sphinx.ext.extlinks')
12176
extlinks = {
12277
'issue': ('https://github.com/sphinx-notes/snippet/issues/%s', '💬%s'),
@@ -138,29 +93,37 @@
13893
'jinja': ('https://jinja.palletsprojects.com/en/latest/', None),
13994
}
14095

141-
#
96+
extensions.append('sphinx_sitemap')
97+
sitemap_filename = "sitemap.xml"
98+
sitemap_url_scheme = "{link}"
99+
100+
extensions.append('sphinxext.opengraph')
101+
ogp_site_url = html_baseurl
102+
ogp_site_name = project
103+
ogp_image = html_baseurl + '/' + html_logo
104+
142105
extensions.append('sphinxnotes.comboroles')
143106
comboroles_roles = {
144107
'parsed_literal': (['literal'], True),
145108
}
146-
#
147109

148-
#
110+
extensions.append('sphinxnotes.project')
111+
primary_domain = 'any'
112+
149113
# -- Eat your own dog food --------------------------------------------------
150114

151115
# If extensions (or modules to document with autodoc) are in another directory,
152116
# add these directories to sys.path here. If the directory is relative to the
153117
# documentation root, use os.path.abspath to make it absolute, like shown here.
118+
import os
119+
import sys
154120
sys.path.insert(0, os.path.abspath('../src/sphinxnotes'))
155-
extensions.append('snippet.ext')
121+
extensions.append('snippet')
156122

157-
# DOG FOOD CONFIGURATION START
123+
# CUSTOM CONFIGURATION
158124

159125
snippet_config = {
160126
'cache_dir': '/tmp/' + 'sphinxnotes-snippet'
161127
}
162128

163129
extensions.append('sphinxcontrib.asciinema')
164-
165-
# DOG FOOD CONFIGURATION END
166-
#

docs/index.rst

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,23 @@
55
sphinxnotes-snippet
66
===================
77

8-
.. |docs| image:: https://img.shields.io/github/deployments/sphinx-notes/snippet/github-pages
8+
.. |docs| image:: https://img.shields.io/github/deployments/sphinx-notes/snippet/github-pages?label=docs
99
:target: https://sphinx.silverrainz.me/snippet
1010
:alt: Documentation Status
11-
1211
.. |license| image:: https://img.shields.io/github/license/sphinx-notes/snippet
1312
:target: https://github.com/sphinx-notes/snippet/blob/master/LICENSE
1413
:alt: Open Source License
15-
1614
.. |pypi| image:: https://img.shields.io/pypi/v/sphinxnotes-snippet.svg
17-
:target: https://pypi.python.org/pypi/sphinxnotes-snippet
15+
:target: https://pypistats.org/packages/sphinxnotes-snippet
1816
:alt: PyPI Package
19-
2017
.. |download| image:: https://img.shields.io/pypi/dm/sphinxnotes-snippet
2118
:target: https://pypi.python.org/pypi/sphinxnotes-snippet
2219
:alt: PyPI Package Downloads
20+
.. |github| image:: https://img.shields.io/badge/GitHub-181717?style=flat&logo=github&logoColor=white/
21+
:target: https://github.com/sphinx-notes/snippet
22+
:alt: GitHub Repository
2323

24-
|docs| |license| |pypi| |download|
24+
|docs| |license| |pypi| |download| |github|
2525

2626
Introduction
2727
============
@@ -44,12 +44,14 @@ Getting Started
4444
We assume you already have a Sphinx documentation,
4545
if not, see `Getting Started with Sphinx`_.
4646

47+
4748
First, downloading extension from PyPI:
4849

4950
.. code-block:: console
5051
5152
$ pip install sphinxnotes-snippet
5253
54+
5355
Then, add the extension name to ``extensions`` configuration item in your
5456
:parsed_literal:`conf.py_`:
5557

0 commit comments

Comments
 (0)