File: index.md

package info (click to toggle)
python-sphinx-examples 0.0.5-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, trixie
  • size: 152 kB
  • sloc: python: 127; makefile: 22
file content (94 lines) | stat: -rw-r--r-- 1,860 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# `sphinx-examples`

A small sphinx extension to add "example snippets" that allow you to show off source markdown and the result of rendering it in Sphinx.

For example:

````{example} Showing off a card and note directive

:::{note}
Here's a sample note!
:::


````

:::{warning}
This currently only works with MyST Markdown content, it will not work if you've written your documentation in reStructuredText.
:::


## Install

Install with pip:

```console
$ pip install sphinx-examples
```

## Use

The `{example}` directive allows you to show off some source markdown, and the result of rendering it.
It is meant to help you demonstrate functionality of a theme, extension, syntax, etc.
For example:

````{example} Using the example directive
```{example} Example title
Here's my **example**!
```
````

### Reverse source and result

You can reverse the order of `source` and `result` by using the `:reverse:` flag, like so:

````{example}
```{example} Reversed source and result
:reverse:
Here's my **example**!
```
````

You can also remove the parent container of the source/result blocks in case you wish to demonstrate something that would not work properly inside a container:

### Remove the container with simple mode

You can remove the Sphinx Design container entirely, which simply places the source / result next to one another.
This is useful if the container would prevent you from demonstrating some functionality:

````{example} No container so we can show off a margin
:no-container:

```{example}
:no-container:

:::{margin}
Here's my **margin content**!
:::

```
````

### Add your own class

You can add your own classes to examples as well.
For example:

````{example}
:no-container:

```{example} A full-width example
:class: full-width
:no-container:

:::{note}
A full-width note!
:::

```
````

```{toctree}
reference
changelog
```