Skip to content

Commit 1014f8f

Browse files
authored
Merge pull request #47 from executablebooks/fix-admonition-padding
👌 IMPROVE: Make padding the same as admonitions
2 parents f30d7d5 + d8158d5 commit 1014f8f

File tree

5 files changed

+94
-55
lines changed

5 files changed

+94
-55
lines changed

docs/requirements.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
sphinx>=3.0
22
sphinx-book-theme
3-
myst-nb
3+
myst-parser
44
sphinxcontrib-bibtex
5+
sphinx_togglebutton

docs/source/conf.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,12 @@
1111
# Add any Sphinx extension module names here, as strings. They can be
1212
# extensions coming with Sphinx (named "sphinx.ext.*") or your custom
1313
# ones.
14-
extensions = ["sphinx_proof", "myst_parser", "sphinxcontrib.bibtex"]
14+
extensions = [
15+
"sphinx_proof",
16+
"myst_parser",
17+
"sphinxcontrib.bibtex",
18+
"sphinx_togglebutton",
19+
]
1520

1621
# Add any paths that contain templates here, relative to this directory.
1722
templates_path = ["_templates"]

docs/source/syntax.md

Lines changed: 71 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ This documentation utilized the [Markedly Structured Text (MyST)](https://myst-p
66

77
This package utilizes a [Sphinx domain](https://www.sphinx-doc.org/en/master/usage/restructuredtext/domains.html) - named "proof" - to describe and link typeset markup objects (theorems, proofs, corollaries, etc.) which we think belong together. All directives follow the pattern `{<domain_name>:<typeset>}` while all the roles follow the pattern `{<domain_name>:ref}`. To utilize any directive in the `proof` domain follow the pattern `{prf:<typeset>}`. To reference any directive follow the pattern `{prf:ref}`.
88

9-
## Proofs
9+
## Collection of Directives
10+
11+
### Proofs
1012

1113
A proof directive can be included using the `prf:proof` pattern. Unlike the other directives provided through this extension, a proof directive does not include any parameters nor does it require any arguments. A proof directive can easily be referenced through [targets](https://myst-parser.readthedocs.io/en/latest/using/syntax.html#targets-and-cross-referencing).
1214

@@ -66,7 +68,7 @@ Hence $\| y - z \| \geq \| y - \hat y \|$, which completes the proof.
6668
_Source:_ [QuantEcon](https://python-advanced.quantecon.org/orth_proj.html#The-Orthogonal-Projection-Theorem)
6769

6870

69-
## Theorems
71+
### Theorems
7072

7173
A theorem directive can be included using the `prf:theorem` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
7274

@@ -133,11 +135,11 @@ The vector $\hat y$ is called the **orthogonal projection** of $y$ onto $S$.
133135

134136
_Source:_ [QuantEcon](https://python-advanced.quantecon.org/orth_proj.html#The-Orthogonal-Projection-Theorem)
135137

136-
### Referencing Theorems
138+
#### Referencing Theorems
137139

138140
You can refer to a theorem using the `{prf:ref}` role like: ```{prf:ref}`my-theorem` ```, which will replace the reference with the theorem number like so: {prf:ref}`my-theorem`. When an explicit text is provided, this caption will serve as the title of the reference. For example, ```{prf:ref}`Orthogonal-Projection-Theorem <my-theorem>` ``` will produce: {prf:ref}`Orthogonal-Projection-Theorem <my-theorem>`.
139141

140-
## Axioms
142+
### Axioms
141143

142144
An axiom directive can be included using the `prf:theorem` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
143145

@@ -171,12 +173,12 @@ Every Cauchy sequence on the real line is convergent.
171173

172174
_Source:_ {cite}`economic-dynamics-book`
173175

174-
### Referencing Axioms
176+
#### Referencing Axioms
175177

176178
You can refer to an axiom using the `{prf:ref}` role like: ```{prf:ref}`my-axiom` ```, which will replace the reference with the axiom number like so: {prf:ref}`my-axiom`. When an explicit text is provided, this caption will serve as the title of the reference.
177179

178180

179-
## Lemmas
181+
### Lemmas
180182

181183
A lemma directive can be included using the `prf:lemma` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
182184

@@ -222,12 +224,12 @@ K(\hat F, \theta) = (\theta I - C'\hat P C)^{-1} C' \hat P (A - B \hat F)
222224

223225
_Source:_ [QuantEcon](https://python-advanced.quantecon.org/robustness.html#Appendix)
224226

225-
### Referencing Lemmas
227+
#### Referencing Lemmas
226228

227229
You can refer to a lemma using the `{prf:ref}` role like: ```{prf:ref}`my-lemma` ```, which will replace the reference with the lemma number like so: {prf:ref}`my-lemma`. When an explicit text is provided, this caption will serve as the title of the reference.
228230

229231

230-
## Definitions
232+
### Definitions
231233

232234
A definition directive can be included using the `prf:definition` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
233235

@@ -276,11 +278,11 @@ $$
276278

277279
_Source:_ [QuantEcon](https://python-advanced.quantecon.org/von_neumann_model.html#Duality)
278280

279-
### Referencing Definitions
281+
#### Referencing Definitions
280282

281283
You can refer to a definition using the `{prf:ref}` role like: ```{prf:ref}`my-definition` ```, which will replace the reference with the definition number like so: {prf:ref}`my-definition`. When an explicit text is provided, this caption will serve as the title of the reference.
282284

283-
## Criteria
285+
### Criteria
284286

285287
A criterion directive can be included using the `prf:criterion` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
286288

@@ -324,12 +326,12 @@ and only if for all non-zero integers $m$,
324326

325327
_Source:_ [Wikipedia](https://en.wikipedia.org/wiki/Equidistributed_sequence#Weyl's_criterion)
326328

327-
### Referencing Criteria
329+
#### Referencing Criteria
328330

329331
You can refer to a criterion using the `{prf:ref}` role like: ```{prf:ref}`weyls-criterion` ```, which will replace the reference with the criterion number like so: {prf:ref}`weyls-criterion`. When an explicit text is provided, this caption will serve as the title of the reference.
330332

331333

332-
## Remarks
334+
### Remarks
333335

334336
A remark directive can be included using the `prf:remark` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
335337

@@ -384,12 +386,12 @@ This property is called **spherical symmetry** (see p 81. in Leamer
384386
_Source:_ [QuantEcon](https://python-advanced.quantecon.org/black_litterman.html)
385387

386388

387-
### Referencing Remarks
389+
#### Referencing Remarks
388390

389391
You can refer to a remark using the `{prf:ref}` role like: ```{prf:ref}`my-remark` ```, which will replace the reference with the remark number like so: {prf:ref}`my-remark`. When an explicit text is provided, this caption will serve as the title of the reference.
390392

391393

392-
## Conjectures
394+
### Conjectures
393395

394396
**Example**
395397

@@ -409,11 +411,11 @@ This is a dummy conjecture to illustrate that one can use math in titles.
409411
```
410412
``````
411413

412-
### Referencing Conjectures
414+
#### Referencing Conjectures
413415

414416
You can refer to a conjecture using the `{prf:ref}` role like: ```{prf:ref}`my-conjecture` ```, which will replace the reference with the conjecture number like so: {prf:ref}`my-conjecture`. When an explicit text is provided, this caption will serve as the title of the reference.
415417

416-
## Corollaries
418+
### Corollaries
417419

418420
A corollary directive can be included using the `prf:corollary` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
419421

@@ -449,12 +451,12 @@ that $\vert \vert A \vert \vert < 1$.
449451

450452
_Source:_ [QuantEcon](https://python-intro.quantecon.org/_static/lecture_specific/linear_models/iteration_notes.pdf)
451453

452-
### Referencing Corollaries
454+
#### Referencing Corollaries
453455

454456
You can refer to a corollary using the `{prf:ref}` role like: ```{prf:ref}`my-corollary` ```, which will replace the reference with the corollary number like so: {prf:ref}`my-corollary`. When an explicit text is provided, this caption will serve as the title of the reference.
455457

456458

457-
## Algorithms
459+
### Algorithms
458460

459461

460462
An algorithm directive can be included using the `prf:algorithm` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
@@ -512,12 +514,12 @@ An algorithm directive can be included using the `prf:algorithm` pattern. The di
512514

513515
_Source:_ [Wikipedia](https://en.wikipedia.org/wiki/Ford%E2%80%93Fulkerson_algorithm)
514516

515-
### Referencing Algorithms
517+
#### Referencing Algorithms
516518

517519
You can refer to a algorithms using the `{prf:ref}` role like: ```{prf:ref}`my-algorithm` ```, which will replace the reference with the algorithm number like so: {prf:ref}`my-algorithm`. When an explicit text is provided, this caption will serve as the title of the reference.
518520

519521

520-
## Examples
522+
### Examples
521523

522524
An example directive can be included using the `prf:example` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
523525

@@ -581,12 +583,12 @@ ex2.simulate(x0)
581583

582584
_Source:_ [QuantEcon](https://python.quantecon.org/lq_inventories.html#Example-2)
583585

584-
### Referencing Examples
586+
#### Referencing Examples
585587

586588
You can refer to an example using the `{prf:ref}` role like: ```{prf:ref}`my-example` ```, which will replace the reference with the example number like so: {prf:ref}`my-example`. When an explicit text is provided, this caption will serve as the title of the reference.
587589

588590

589-
## Properties
591+
### Properties
590592

591593
A property directive can be included using the `prf:property` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
592594

@@ -618,11 +620,11 @@ This is a dummy property to illustrate the directive.
618620
```
619621
``````
620622

621-
### Referencing Properties
623+
#### Referencing Properties
622624

623625
You can refer to a property using the `{prf:ref}` role like: ```{prf:ref}`my-property` ```, which will replace the reference with the property number like so: {prf:ref}`my-property`. When an explicit text is provided, this caption will serve as the title of the reference.
624626

625-
## Observations
627+
### Observations
626628

627629
An observation directive can be included using the `prf:observation` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
628630

@@ -654,11 +656,11 @@ This is a dummy observation directive.
654656
```
655657
``````
656658

657-
### Referencing Observations
659+
#### Referencing Observations
658660

659661
You can refer to an observation using the `{prf:ref}` role like: ```{prf:ref}`my-observation` ```, which will replace the reference with the observation number like so: {prf:ref}`my-observation`. When an explicit text is provided, this caption will serve as the title of the reference.
660662

661-
## Propositions
663+
### Propositions
662664

663665
A proposition directive can be included using the `prf:proposition` pattern. The directive is enumerated by default and can take in an optional title argument. The following options are also supported:
664666

@@ -690,6 +692,48 @@ This is a dummy proposition directive.
690692
```
691693
``````
692694

693-
### Referencing Propositions
695+
#### Referencing Propositions
694696

695697
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.
698+
699+
## How to Hide Content
700+
701+
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`.
702+
703+
For Sphinx projects, add `"sphinx_togglebutton"` to your `extensions` list in `conf.py` to activate the extension
704+
705+
```python
706+
extensions = [
707+
...
708+
"sphinx_togglebutton"
709+
...
710+
]
711+
```
712+
713+
For Jupyter Book projects, add `sphinx_togglebutton` under `extra_extensions`
714+
715+
```yaml
716+
sphinx:
717+
extra_extensions:
718+
- sphinx_togglebutton
719+
```
720+
721+
To hide the directive, simply add `:class: dropdown` as a directive option.
722+
723+
**Example**
724+
725+
```{prf:theorem}
726+
:class: dropdown
727+
728+
This is an example of how to hide the content of a directive.
729+
```
730+
731+
**MyST Syntax**:
732+
733+
````
734+
```{prf:theorem}
735+
:class: dropdown
736+
737+
This is an example of how to hide the content of a directive.
738+
```
739+
````

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"sphinx-book-theme",
3434
"sphinxcontrib-bibtex",
3535
"myst-parser",
36+
"sphinx_togglebutton",
3637
],
3738
}
3839

0 commit comments

Comments
 (0)