Skip to content

Commit fcae485

Browse files
authored
Improve README.md
1 parent ae74f84 commit fcae485

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

README.md

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ print("this will not be run")
8181

8282
Sometimes you might wish to run code blocks that depend on entities to already
8383
be declared in the scope of the code, without explicitly declaring them. There
84-
are currently two ways you can do this with pytest-markdown:
84+
are currently three ways you can do this with pytest-markdown:
8585

86-
### Injecting global/local variables
86+
### Method 1: Injecting global/local variables
8787

8888
If you have some common imports or other common variables that you want to make
8989
use of in snippets, you can add them by creating a `pytest_markdown_docs_globals`
@@ -104,7 +104,7 @@ print(myvar, math.pi)
104104
```
105105
````
106106

107-
### Fixtures
107+
### Method 2: Fixtures
108108

109109
You can use both `autouse=True` pytest fixtures in a conftest.py or named fixtures with
110110
your markdown tests. To specify named fixtures, add `fixture:<name>` markers to the code
@@ -120,7 +120,7 @@ assert captured.out == "hello\n"
120120

121121
As you can see above, the fixture value will be injected as a global. For `autouse=True` fixtures, the value is only injected as a global if it's explicitly added using a `fixture:<name>` marker.
122122

123-
### Depending on previous snippets
123+
### Method 3: Depending on previous snippets
124124

125125
If you have multiple snippets following each other and want to keep the side
126126
effects from the previous snippets, you can do so by adding the `continuation`
@@ -136,19 +136,17 @@ assert a + " world" == "hello world"
136136
```
137137
````
138138

139-
### Compatibility with Material for MkDocs
140-
141-
Material for Mkdocs is not compatible with the default syntax.
142-
143-
But if the extension `pymdownx.superfences` is configured for mkdocs, the brace format can be used:
144-
````markdown
145-
```{.python continuation}
146-
````
147-
148-
You will need to call pytest with the `--markdown-docs-syntax` option:
149-
```shell
150-
pytest --markdown-docs --markdown-docs-syntax=superfences
151-
```
139+
If you'd like to hide some code blocks from readers (e.g. to hide boilerplate code) you can use the [`markdown-hide-code`](https://pypi.org/project/markdown-hide-code/) extension (assuming you're using the `markdown` library or `mkdocs` to render your documentation).
140+
141+
> [!NOTE]
142+
> Material for Mkdocs is not compatible with the default syntax. But if the extension `pymdownx.superfences` is [configured](https://squidfunk.github.io/mkdocs-material/setup/extensions/python-markdown-extensions/#superfences) for mkdocs, the brace syntax can be used:
143+
> ````markdown
144+
> ```python {continuation}
145+
> ````
146+
> You will need to call pytest with the `--markdown-docs-syntax` option:
147+
> ```shell
148+
> pytest --markdown-docs --markdown-docs-syntax=superfences
149+
> ```
152150
153151
## MDX Comments for Metadata Options
154152
In .mdx files, you can use MDX comments to provide additional options for code blocks. These comments should be placed immediately before the code block and take the following form:

0 commit comments

Comments
 (0)