Skip to content

Commit 2284253

Browse files
Add doctests to docs section
1 parent 3dabd64 commit 2284253

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

docs/compatibility.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ Uninstantiated classes are only rendered if they are given as the child of an
88
instantiated element.
99

1010
```py
11+
>>> import pyhtml as p
1112
>>> p.br
1213
<class 'pyhtml.__tags.generated.br'>
1314
>>> print(str(p.html(p.body(p.br))))

docs/learn/advanced.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ in the output HTML, which can be useful for debugging your server from your web
6565
browser.
6666

6767
```py
68+
>>> import pyhtml as p
6869
>>> comment = p.Comment("This is an HTML comment")
6970
>>> print(str(comment))
7071
<!--
@@ -84,6 +85,7 @@ Sometimes, you may wish to embed an existing HTML string inside of PyHTML. You
8485
can do this using the `p.DangerousRawHtml` tag.
8586

8687
```py
88+
>>> import pyhtml as p
8789
>>> raw = p.DangerousRawHtml("<p>Scary!</p>")
8890
>>> print(str(raw))
8991
<p>Scary!</p>
@@ -101,9 +103,9 @@ you'll need to do create a custom tag. However if you really need to, you can
101103
use the `create_tag` function
102104

103105
```py
104-
import pyhtml as p
106+
>>> import pyhtml as p
107+
>>> fancy = p.create_tag('fancy')
105108

106-
fancy = p.create_tag('fancy')
107109
```
108110

109111
This tag can be used like any other PyHTML tag:
@@ -129,7 +131,11 @@ The `create_tag` function also allows you to specify a rendering strategy.
129131
For example, to create a self-closing tag, you can use:
130132

131133
```py
132-
closure = p.create_tag('closure', p.SelfClosingTag)
134+
>>> import pyhtml as p
135+
>>> closure = p.create_tag('closure', p.SelfClosingTag)
136+
>>> closure()
137+
<closure/>
138+
133139
```
134140

135141
## Advanced custom tags

docs/learn/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ by passing it to the Python `str` function.
1515
This the standard way to import the PyHTML library:
1616

1717
```py
18-
import pyhtml as p
18+
>>> import pyhtml as p
19+
1920
```
2021

2122
All of the PyHTML tags can then be accessed within an object named `p`.

0 commit comments

Comments
 (0)