A Sphinx extension that fills the index based on definitions in a Sphinx book
Project description
Sphinx Indexed Definitions
Introduction
This Sphinx extension provides an easy way to add entries to a genreated index based on strong, emphasized and/or literal terms used within prf:definition admonitions and the title of the adminition.
What does it do?
If you code includes an admonition with the source code
:::{prf:definition} Lorem
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse **Pharetra**, ex ut commodo varius,
est justo vestibulum nunc, *(id) dignissim* lorem nibh in mauris. Duis varius lorem et neque posuere,
ac elementum eros consequat. Maecenas sed risus suscipit, **fermentum Kelvin** quam vitae, consectetur
augue. Maecenas aliquam leo vitae velit interdum efficitur.
:::
this extension, once loaded, will add (with default settings) the terms Lorem, pharetra, id dignissim, dignissim and fermentum Kelvin to the generated index.
This extension can be used in conjunction with the regular usage if generating an index, as explained at Indexes.
Installation
To use this extenstion, follow these steps (be aware, more steps then usual):
Step 1: Install the Package
Install the module sphinx-indexed-definitions package using pip:
pip install git+https://github.com/TeachBooks/Sphinx-Indexed-Definitions.git
Step 2: Add to requirements.txt
Make sure that the package is included in your project's requirements.txt to track the dependency:
git+https://github.com/TeachBooks/Sphinx-Indexed-Definitions.git
Step 3: Enable in _config.yml
In your _config.yml file, add the extension to the list of extra Sphinx extensions (important: underscore, not dash this time):
sphinx:
extra_extensions:
.
.
.
- sphinx_indexed_definitions
.
.
.
Step 4: Add the general index to ToC
To do this, if you have not done this, please follow the instructions at Add the general index to your table of contents.
Configuration
The extension provides several configuration values, which can be added to _config.yml if the default value should be changed:
sphinx:
config:
-
-
-
sphinx_indexed_defs_indexed_nodes: ['strong','emphasis'] # default value
sphinx_indexed_defs_skip_indices: [] # default value
sphinx_indexed_defs_lowercase_indices: true # default value
sphinx_indexed_defs_index_titles: true # default value
sphinx_indexed_defs_capital_words: [] # default value
sphinx_indexed_defs_remove_brackets: true # default value
sphinx_indexed_defs_force_main: true # default value
sphinx_indexed_defs_index_theorems: true # default value
-
-
-
sphinx_indexed_defs_indexed_nodes:['strong','emphasis'](default) or list of strings:- All nodes of the provided classes from the Python submodule
docutils.nodeswill be extracted and converted to entries in the index. - Supported classes are
strong,emphasisandliteral.
- All nodes of the provided classes from the Python submodule
sphinx_indexed_defs_skip_indices:[](default) or list of strings:- All entries that match at least one regular expression within the provided list will not be added to the index (i.e. skipped).
- An example is
['\bdet\w*','\$i\$-th entry'], which causes any entry that starts with det to be skipped and the entry $i$-th entry will also be skipped. - Note that special characters must be escaped.
sphinx_indexed_defs_lowercase_indices:true(default) orfalse:- If
true, all extracted entries will be converted to lower case, except for words that are provided insphinx_indexed_defs_capital_wordsand a prefixed set of common names from beta sciences. - This prefixed set can be found in the source
py-file of this extension. - Users are welcome to add names to this list by forking and opening a pull request.
- If
false, all extracted entries will be added to the index as written.
- If
sphinx_indexed_defs_index_titles:true(default) orfalse:- If
true, any title provided in aprf:definitionadmonition will also be added as an entry to the index. - If
false, all titles will be ignored.
- If
sphinx_indexed_defs_capital_words:[](default) or list of strings:- See
sphinx_indexed_defs_lowercase_indices.
- See
sphinx_indexed_defs_remove_brackets:true(default) orfalse:- If
true, any extracted term containing words between matching opening and closing round brackets, i.e.(and), are converted to two entries: one with the entire term with all round brackets removed, and one with all words between matching round brackets removed (including the brackets). - An example: the extracted term
(id) dignissimwill result in two entries:id dignissimanddignissim. - If
false, no parsing of terms with brackets will occur and terms are converted to entries as written.
- If
sphinx_indexed_defs_force_main:true(default) orfalse:- If
true, all extracted terms will be added as the main entry to the index, which means the entry will be emphasized in the generated index. - If
false, extracted terms will not be emphasized in the generated index.sphinx_indexed_defs_index_theorems:true(default) orfalse: - If
true, any title provided in aprf:theorem,prf:lemma,prf:conjecture,prf:corollaryorprf:propositionadmonition will also be added as an entry to the index. - If
false, all titles provided inprf:theorem,prf:lemma,prf:conjecture,prf:corollaryandprf:propositionadmonitions will be ignored.
- If
Provided code
In case a prf:definition admonition should be skipped during indexing, add the class skipindexing to the admonition, for example:
:::{prf:definition} Lorem
:class: skipindexing
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse **Pharetra**, ex ut commodo varius,
est justo vestibulum nunc, *(id) dignissim* lorem nibh in mauris. Duis varius lorem et neque posuere,
ac elementum eros consequat. Maecenas sed risus suscipit, **fermentum Kelvin** quam vitae, consectetur
augue. Maecenas aliquam leo vitae velit interdum efficitur.
:::
Contribute
This tool's repository is stored on GitHub. If you'd like to contribute, you can create a fork and open a pull request on the GitHub repository.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sphinx_indexed_definitions-1.0.0.tar.gz.
File metadata
- Download URL: sphinx_indexed_definitions-1.0.0.tar.gz
- Upload date:
- Size: 10.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e1a1aa66ffc22d9859d7ea32d654a84c6d1fc148145bc0a81141471a1bc696c4
|
|
| MD5 |
c946adfa7eb0baaee4eafd10c79b9da1
|
|
| BLAKE2b-256 |
8139f7aba621fcf012c058c4a356a9e52ba4482882d9dbf78ee5bfc802569093
|
Provenance
The following attestation bundles were made for sphinx_indexed_definitions-1.0.0.tar.gz:
Publisher:
python-publish.yml on TeachBooks/Sphinx-Indexed-Definitions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_indexed_definitions-1.0.0.tar.gz -
Subject digest:
e1a1aa66ffc22d9859d7ea32d654a84c6d1fc148145bc0a81141471a1bc696c4 - Sigstore transparency entry: 204397410
- Sigstore integration time:
-
Permalink:
TeachBooks/Sphinx-Indexed-Definitions@46cf7f3b268d5d55a020075640f04dc6e7da16c8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/TeachBooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@46cf7f3b268d5d55a020075640f04dc6e7da16c8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sphinx_indexed_definitions-1.0.0-py3-none-any.whl.
File metadata
- Download URL: sphinx_indexed_definitions-1.0.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dfe5cf3e6e12bfb349490ac4d1b0ba405d1a2fc4e417086c541b903aa18e8908
|
|
| MD5 |
87af5f7fa4b2aee8407b02e080339a6c
|
|
| BLAKE2b-256 |
a0c72d9c0e0d97825ba98998fe5d6a9ab039d46c1b493aeab7e7c5f3e648f0ad
|
Provenance
The following attestation bundles were made for sphinx_indexed_definitions-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on TeachBooks/Sphinx-Indexed-Definitions
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sphinx_indexed_definitions-1.0.0-py3-none-any.whl -
Subject digest:
dfe5cf3e6e12bfb349490ac4d1b0ba405d1a2fc4e417086c541b903aa18e8908 - Sigstore transparency entry: 204397411
- Sigstore integration time:
-
Permalink:
TeachBooks/Sphinx-Indexed-Definitions@46cf7f3b268d5d55a020075640f04dc6e7da16c8 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/TeachBooks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@46cf7f3b268d5d55a020075640f04dc6e7da16c8 -
Trigger Event:
push
-
Statement type: