diff --git a/README.md b/README.md index 12f22a7..9c2a0ed 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ This package contains a [Sphinx](http://www.sphinx-doc.org/en/master/) extension for producing proof, theorem, axiom, lemma, definition, criterion, remark, conjecture, -corollary, algorithm, example, property, observation and proposition directives. +corollary, algorithm, example, property, observation, proposition and assumption directives. ## Get started diff --git a/docs/source/index.md b/docs/source/index.md index 71dcf78..21ebe67 100644 --- a/docs/source/index.md +++ b/docs/source/index.md @@ -17,7 +17,7 @@ zreferences This package contains a [Sphinx](http://www.sphinx-doc.org/en/master/) extension for producing proof, theorem, axiom, lemma, definition, criterion, remark, conjecture, -corollary, algorithm, example, property, observation and proposition directives. +corollary, algorithm, example, property, observation, proposition and assumption directives. **Features**: diff --git a/docs/source/syntax.md b/docs/source/syntax.md index e430075..044c578 100644 --- a/docs/source/syntax.md +++ b/docs/source/syntax.md @@ -696,6 +696,43 @@ This is a dummy proposition directive. You can refer to a proposition using the `{prf:ref}` role like: ```{prf:ref}`my-proposition` ```, which will replace the reference with the proposition number like so: {prf:ref}`my-proposition`. When an explicit text is provided, this caption will serve as the title of the reference. + +### Assumptions + +An assumption directive can be included using the `prf:assumption` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported: + +* `label` : text + + A unique identifier for your assumption that you can use to reference it with `{prf:ref}`. Cannot contain spaces or special characters. +* `class` : text + + Value of the assumption’s class attribute which can be used to add custom CSS or JavaScript. +* `nonumber` : flag (empty) + + Turns off assumption auto numbering. + +**Example** + +```{prf:assumption} +:label: my-assumption + +This is a dummy assumption directive. +``` + +**MyST Syntax** + +``````md +```{prf:assumption} +:label: my-assumption + +This is a dummy assumption directive. +``` +`````` + +#### Referencing Assumptions + +You can refer to an assumption using the `{prf:ref}` role like: ```{prf:ref}`my-assumption` ```, which will replace the reference with the assumption number like so: {prf:ref}`my-assumption`. When an explicit text is provided, this caption will serve as the title of the reference. + ## How to Hide Content Directive content can be hidden using the `dropdown` class which is available through [sphinx-togglebutton](https://sphinx-togglebutton.readthedocs.io/en/latest/). If your project utilizes the [MyST-NB](https://myst-nb.readthedocs.io/en/latest/) extension, there is no need to activate `sphinx-togglebutton` since it is already bundled with `MyST-NB`. diff --git a/setup.py b/setup.py index 4a16c5d..8975b4c 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,8 @@ LONG_DESCRIPTION = """ This package contains a [Sphinx](http://www.sphinx-doc.org/en/master/) extension for producing proof, theorem, axiom, lemma, definition, criterion, remark, conjecture, -corollary, algorithm, example, property, observation and proposition directives. +corollary, algorithm, example, property, observation, proposition, and +assumption directives. This project is maintained and supported by [najuzilu](https://github.com/najuzilu). """ diff --git a/sphinx_proof/_static/proof.css b/sphinx_proof/_static/proof.css index 51e0c9f..f975944 100644 --- a/sphinx_proof/_static/proof.css +++ b/sphinx_proof/_static/proof.css @@ -194,3 +194,14 @@ div.proposition { div.proposition p.admonition-title { background-color: var(--note-title-color); } +/********************************************* +* Assumption * +*********************************************/ +div.assumption { + border-color: var(--hint-border-color); + background-color: var(--hint-title-color); +} + +div.assumption p.admonition-title { + background-color: var(--hint-title-color); +} diff --git a/sphinx_proof/nodes.py b/sphinx_proof/nodes.py index 8e7a429..5f164ae 100644 --- a/sphinx_proof/nodes.py +++ b/sphinx_proof/nodes.py @@ -183,6 +183,10 @@ class unenumerable_node(nodes.Admonition, nodes.Element): pass +class assumption_node(nodes.Admonition, nodes.Element): + pass + + NODE_TYPES = { "axiom": axiom_node, "theorem": theorem_node, @@ -197,4 +201,5 @@ class unenumerable_node(nodes.Admonition, nodes.Element): "property": property_node, "observation": observation_node, "proposition": proposition_node, + "assumption": assumption_node, } diff --git a/sphinx_proof/proof_type.py b/sphinx_proof/proof_type.py index 12dafb2..9176e97 100644 --- a/sphinx_proof/proof_type.py +++ b/sphinx_proof/proof_type.py @@ -89,6 +89,12 @@ class PropositionDirective(ElementDirective): name = "proposition" +class AssumptionDirective(ElementDirective): + """A custom assumption directive.""" + + name = "assumption" + + PROOF_TYPES = { "axiom": AxiomDirective, "theorem": TheoremDirective, @@ -103,4 +109,5 @@ class PropositionDirective(ElementDirective): "property": PropertyDirective, "observation": ObservationDirective, "proposition": PropositionDirective, + "assumption": AssumptionDirective, } diff --git a/sphinx_proof/translations/jsons/Assumption.json b/sphinx_proof/translations/jsons/Assumption.json new file mode 100644 index 0000000..17e55b3 --- /dev/null +++ b/sphinx_proof/translations/jsons/Assumption.json @@ -0,0 +1 @@ +[{"language":"English","symbol":"en","text":"Assumption"}]