Skip to content

Commit

Permalink
chore: Update cookiecutter tempalte
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverRainZ committed Mar 23, 2024
1 parent 09c6f5c commit 268dd02
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 40 deletions.
6 changes: 1 addition & 5 deletions .cruft.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"template": "https://github.com/sphinx-notes/template",
"commit": "c781308dbd84e739727ce09aaf798444ced1e7e4",
"commit": "0b7d8aa478b37114cef369a217bd1d463e369d37",
"checkout": null,
"context": {
"cookiecutter": {
Expand All @@ -14,10 +14,6 @@
"github_repo": "snippet",
"pypi_name": "sphinxnotes-snippet",
"pypi_owner": "SilverRainZ",
"dependencies": [
"Sphinx >= 4"
],
"additional_docs": [],
"_template": "https://github.com/sphinx-notes/template"
}
},
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is generated from sphinx-notes/template.
# This file is generated from sphinx-notes/cookiecutter.
# You need to consider modifying the TEMPLATE or modifying THIS FILE.

include LICENSE
Expand Down
37 changes: 31 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,37 +1,62 @@
# This file is generated from sphinx-notes/template.
# This file is generated from sphinx-notes/cookiecutter.
# You need to consider modifying the TEMPLATE or modifying THIS FILE.

LANG = en_US.UTF-8

MAKE = make
PY = python3
RM = rm -rf
MAKE = make
PY = python3
RM = rm -rf

# Build sphinx documentation.
.PHONY: docs
docs:
$(MAKE) -C docs/

# Run unittest.
.PHONY: test
test:
$(PY) -m unittest discover -s tests -v

# Build distribution package, for "install" or "upload".
.PHONY: dist
dist: pyproject.toml
$(RM) dist/ # clean up old dist
$(PY) -m build

# Install distribution package to user directory.
#
# NOTE: It may breaks your system-level packages, use at your own risk.
.PHONY: install
install: dist
export PIP_BREAK_SYSTEM_PACKAGES=1 # required by Python 3.11+, see PEP-668
$(PY) -m pip install --user --no-deps --force-reinstall dist/*.whl

# Publish wheel to PyPI offical server <https://pypi.org/> when you want to
# You should have a PyPI account and have PyPI token configured.
#
# See also https://packaging.python.org/en/latest/tutorials/packaging-projects/#uploading-the-distribution-archives
.PHONY: upload
upload: dist
$(PY) -m twine upload --repository pypi $</*

.PHONY: test-upload
test-upload: dist
# Same to the aboved "upload" target, but this publishs to PyPI test server
# <https://test.pypi.org/>.
.PHONY: upload-test
upload-test: dist
$(PY) -m twine upload --repository testpypi $</*

# Keep up to date with the latest template.
# See also https://github.com/sphinx-notes/cookiecutter.
.PHONY: update-template
update-template:
$(PY) -m cruft update

# Update project version.
.PHONY: bump-version
bump-version:
@echo -n "Please enter the version to bump: "
@read version && $(PY) -m cruft update --variables-to-update "{ \"version\" : \"$$version\" }"

# Usage: make cli args=--help
.PHONY: cli
cli:
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. This file is generated from sphinx-notes/template.
.. This file is generated from sphinx-notes/cookiecutter.
You need to consider modifying the TEMPLATE or modifying THIS FILE.
===================
Expand All @@ -17,7 +17,7 @@ sphinxnotes-snippet
:target: https://pypi.python.org/pypi/sphinxnotes-snippet
:alt: PyPI Package

.. image:: https://img.shields.io/pypi/dw/sphinxnotes-snippet
.. image:: https://img.shields.io/pypi/dm/sphinxnotes-snippet
:target: https://pypi.python.org/pypi/sphinxnotes-snippet
:alt: PyPI Package Downloads

Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is generated from sphinx-notes/template.
# This file is generated from sphinx-notes/cookiecutter.
# You need to consider modifying the TEMPLATE or modifying THIS FILE.

# Minimal makefile for Sphinx documentation
Expand Down
Empty file added docs/_images/.gitkeep
Empty file.
File renamed without changes
11 changes: 11 additions & 0 deletions docs/_templates/confval.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

:Type: :py:class:`{{ type }}`
:Default: ``{{ default }}``
{% if choice %}:Choices: {% for c in choice %}``{{ c }}`` {% endfor %}{% endif %}
{% if versionadded %}:Version added: :version:`{{ versionadded }}`{% endif %}
{% if versionchanged %}:Version changed:{% for i in range(0, versionchanged|count -1, 2) %}
:version:`{{ versionchanged[i] }}`
{{ versionchanged[i+1] }}{% endfor %}{% endif %}

{{ content }}

31 changes: 31 additions & 0 deletions docs/_templates/example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

{% if style is not defined or style == 'tab' %}
.. tab-set::

.. tab-item:: Result

{% for line in content %}{{ line }}
{% endfor %}

.. tab-item:: reStructuredText

.. code:: rst
{% for line in content %}{{ line }}
{% endfor %}
{% elif style == 'grid' %}
.. grid:: 2

.. grid-item-card:: reStructuredText

.. code:: rst
{% for line in content %}{{ line }}
{% endfor %}
.. grid-item-card:: Result

{% for line in content %}{{ line }}
{% endfor %}
{% endif %}

7 changes: 2 additions & 5 deletions docs/_templates/version.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
.. list-table::
:align: left

* - :ref:`📅 {{ date }} <any-version.date>`
- :tag:`{{ title }}`

:Date: :ref:`📅{{ date }} <any-version.date>`
:Download: :tag:`{{ title }}`

{% for line in content %}
{{ line }}
Expand Down
2 changes: 1 addition & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. This file is generated from sphinx-notes/template.
.. This file is generated from sphinx-notes/cookiecutter.
You need to consider modifying the TEMPLATE or modifying THIS FILE.
==========
Expand Down
59 changes: 44 additions & 15 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is generated from sphinx-notes/template.
# This file is generated from sphinx-notes/cookiecutter.
# You need to consider modifying the TEMPLATE or modifying THIS FILE.

# Configuration file for the Sphinx documentation builder.
Expand Down Expand Up @@ -70,38 +70,66 @@
# It is used to indicate the location of document like canonical_url
html_baseurl = 'https://sphinx.silverrainz.me/snippet'

html_logo = html_favicon = '_images/sphinx-notes.png'
html_logo = html_favicon = '_static/sphinx-notes.png'

# -- Extensions -------------------------------------------------------------

#
extensions.append('sphinxnotes.any')
from sphinxnotes.any import Schema, Field as F
#
version_schema = Schema('version',
name=F(unique=True, referenceable=True, required=True, form=F.Form.LINES),
attrs={'date': F(referenceable=True)},
content=F(form=F.Form.LINES),
description_template=open('_templates/version.rst', 'r').read(),
reference_template='🏷️{{ title }}',
missing_reference_template='🏷️{{ title }}',
ambiguous_reference_template='🏷️{{ title }}')
confval_schema = Schema('confval',
name=F(unique=True, referenceable=True, required=True, form=F.Form.LINES),
attrs={
'type': F(),
'default': F(),
'choice': F(form=F.Form.WORDS),
'versionadded': F(),
'versionchanged': F(form=F.Form.LINES),
},
content=F(),
description_template=open('_templates/confval.rst', 'r').read(),
reference_template='⚙️{{ title }}',
missing_reference_template='⚙️{{ title }}',
ambiguous_reference_template='⚙️{{ title }}')
example_schema = Schema('example',
name=F(referenceable=True),
attrs={'style': F()},
content=F(form=F.Form.LINES),
description_template=open('_templates/example.rst', 'r').read(),
reference_template='📝{{ title }}',
missing_reference_template='📝{{ title }}',
ambiguous_reference_template='📝{{ title }}')
#
any_schemas = [
#
Schema('version',
name=F(unique=True, referenceable=True, required=True, form=F.Form.LINES),
attrs={'date': F(referenceable=True)},
content=F(form=F.Form.LINES),
description_template=open('_templates/version.rst', 'r').read(),
reference_template='💽 {{ title }}',
missing_reference_template='💽 {{ title }}',
ambiguous_reference_template='💽 {{ title }}'),
#
version_schema,
confval_schema,
example_schema,
]
primary_domain = 'any'
#

extensions.append('sphinx.ext.extlinks')
extlinks = {
'issue': ('https://github.com/sphinx-notes/snippet/issues/%s', '💬 %s'),
'pull': ('https://github.com/sphinx-notes/snippet/pull/%s', '🚀 %s'),
'tag': ('https://github.com/sphinx-notes/snippet/releases/tag/%s', '🏷️ %s'),
'issue': ('https://github.com/sphinx-notes/snippet/issues/%s', '💬%s'),
'pull': ('https://github.com/sphinx-notes/snippet/pull/%s', '🚀%s'),
'tag': ('https://github.com/sphinx-notes/snippet/releases/tag/%s', '🏷️%s'),
}

extensions.append('sphinxcontrib.gtagjs')
gtagjs_ids = ['G-E4SNX0WZYV']

extensions.append('sphinxcontrib.asciinema')

#
# -- Eat your own dog food --------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
Expand All @@ -117,3 +145,4 @@
}

# DOG FOOD CONFIGURATION END
#
4 changes: 2 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. This file is generated from sphinx-notes/template.
.. This file is generated from sphinx-notes/cookiecutter.
You need to consider modifying the TEMPLATE or modifying THIS FILE.
.. include:: ../README.rst
Expand Down Expand Up @@ -65,7 +65,7 @@ Contents
The Sphinx Notes Project
========================

This project is a developed by `Shengyu Zhang`__,
The project is developed by `Shengyu Zhang`__,
as part of **The Sphinx Notes Project**.

.. toctree::
Expand Down
2 changes: 1 addition & 1 deletion docs/make.bat
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
REM This file is generated from sphinx-notes/template. DO NOT EDIT.
REM This file is generated from sphinx-notes/cookiecutter. DO NOT EDIT.

@ECHO OFF

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is generated from sphinx-notes/template.
# This file is generated from sphinx-notes/cookiecutter.
# You need to consider modifying the TEMPLATE or modifying THIS FILE.

# This file is used to configure your project.
Expand Down

0 comments on commit 268dd02

Please sign in to comment.