Skip to content

Commit 3449885

Browse files
Make doctests pass
1 parent 7d71b80 commit 3449885

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

README.md

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ with improved documentation and type safety.
3535
<title>
3636
Hello, world!
3737
</title>
38-
<script src="http://example.com/script.js" type="text/javascript"></script>
38+
<script type="text/javascript" src="http://example.com/script.js"></script>
3939
</head>
4040
<body>
4141
<h1>
@@ -46,6 +46,7 @@ with improved documentation and type safety.
4646
</p>
4747
</body>
4848
</html>
49+
4950
```
5051

5152
### Creating elements
@@ -56,7 +57,8 @@ example, to create a `<br>` element, you could use:
5657
```py
5758
>>> line_break = p.br()
5859
>>> print(str(line_break))
59-
<br>
60+
<br/>
61+
6062
```
6163

6264
### Adding children to elements
@@ -71,6 +73,7 @@ could use
7173
<h1>
7274
My awesome website
7375
</h1>
76+
7477
```
7578

7679
### Adding attributes to elements
@@ -81,7 +84,8 @@ element. For example, to create a form submit button, you could use
8184
```py
8285
>>> submit_button = p.input(type="submit")
8386
>>> print(str(submit_button))
84-
<input type="submit" />
87+
<input type="submit"/>
88+
8589
```
8690

8791
### Adding attributes and children
@@ -98,6 +102,7 @@ a link to PyHTML's GitHub page, you could use
98102
<a href="https://github.com/COMP1010UNSW/pyhtml-enhanced">
99103
Take a look at the code
100104
</a>
105+
101106
```
102107

103108
### HTML comments
@@ -110,6 +115,7 @@ You can add comments to HTML (useful for debugging) by using the `Comment` tag.
110115
<!--
111116
This is an HTML comment
112117
-->
118+
113119
```
114120

115121
### Rendering HTML
@@ -121,6 +127,7 @@ Converting your PyHTML into HTML is as simple as stringifying it!
121127
<i>
122128
How straightforward!
123129
</i>
130+
124131
```
125132

126133
### Custom tags
@@ -130,10 +137,11 @@ you'll need to do create a custom tag. However if you really need to, you can
130137
create a class deriving from `Tag`.
131138

132139
```py
133-
>>> class fancytag(Tag):
140+
>>> class fancytag(p.Tag):
134141
... ...
135142
>>> print(fancytag())
136143
<fancytag></fancytag>
144+
137145
```
138146

139147
Refer to the documentation for `Tag` for more information.
@@ -146,14 +154,15 @@ Uninstantiated classes are only rendered if they are given as the child of an
146154
instantiated element.
147155

148156
```py
149-
>>> br
157+
>>> p.br
150158
<class 'pyhtml.__tags.generated.br'>
151-
>>> html(body(br))
159+
>>> print(str(p.html(p.body(p.br))))
152160
<html>
153161
<body>
154-
<br>
162+
<br/>
155163
</body>
156164
</html>
165+
157166
```
158167

159168
Calling an instance of a `Tag` will return a new tag containing all elements of
@@ -162,7 +171,7 @@ modify the original instance, as I found the old behaviour confusing and
162171
bug-prone.
163172

164173
```py
165-
>>> para = p("Base paragraph")
174+
>>> para = p.p("Base paragraph")
166175
>>> para2 = para("Extra text")
167176
>>> para2
168177
<p>
@@ -173,6 +182,7 @@ bug-prone.
173182
<p>
174183
Base paragraph
175184
</p>
185+
176186
```
177187

178188
## Known issues

pyhtml/__init__.py

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""
2-
# PyHTML Enhanced
1+
"""# PyHTML Enhanced
32
43
A library for building HTML documents with a simple and learnable syntax,
54
inspired by, and similar to
@@ -36,7 +35,7 @@
3635
<title>
3736
Hello, world!
3837
</title>
39-
<script src="http://example.com/script.js" type="text/javascript"></script>
38+
<script type="text/javascript" src="http://example.com/script.js"></script>
4039
</head>
4140
<body>
4241
<h1>
@@ -47,6 +46,7 @@
4746
</p>
4847
</body>
4948
</html>
49+
5050
```
5151
5252
### Creating elements
@@ -57,7 +57,8 @@
5757
```py
5858
>>> line_break = p.br()
5959
>>> print(str(line_break))
60-
<br>
60+
<br/>
61+
6162
```
6263
6364
### Adding children to elements
@@ -72,6 +73,7 @@
7273
<h1>
7374
My awesome website
7475
</h1>
76+
7577
```
7678
7779
### Adding attributes to elements
@@ -82,7 +84,8 @@
8284
```py
8385
>>> submit_button = p.input(type="submit")
8486
>>> print(str(submit_button))
85-
<input type="submit" />
87+
<input type="submit"/>
88+
8689
```
8790
8891
### Adding attributes and children
@@ -99,6 +102,7 @@
99102
<a href="https://github.com/COMP1010UNSW/pyhtml-enhanced">
100103
Take a look at the code
101104
</a>
105+
102106
```
103107
104108
### HTML comments
@@ -111,6 +115,7 @@
111115
<!--
112116
This is an HTML comment
113117
-->
118+
114119
```
115120
116121
### Rendering HTML
@@ -122,6 +127,7 @@
122127
<i>
123128
How straightforward!
124129
</i>
130+
125131
```
126132
127133
### Custom tags
@@ -131,10 +137,11 @@
131137
create a class deriving from `Tag`.
132138
133139
```py
134-
>>> class fancytag(Tag):
140+
>>> class fancytag(p.Tag):
135141
... ...
136142
>>> print(fancytag())
137143
<fancytag></fancytag>
144+
138145
```
139146
140147
Refer to the documentation for `Tag` for more information.
@@ -147,14 +154,15 @@
147154
instantiated element.
148155
149156
```py
150-
>>> br
157+
>>> p.br
151158
<class 'pyhtml.__tags.generated.br'>
152-
>>> html(body(br))
159+
>>> print(str(p.html(p.body(p.br))))
153160
<html>
154161
<body>
155-
<br>
162+
<br/>
156163
</body>
157164
</html>
165+
158166
```
159167
160168
Calling an instance of a `Tag` will return a new tag containing all elements of
@@ -163,7 +171,7 @@
163171
bug-prone.
164172
165173
```py
166-
>>> para = p("Base paragraph")
174+
>>> para = p.p("Base paragraph")
167175
>>> para2 = para("Extra text")
168176
>>> para2
169177
<p>
@@ -174,6 +182,7 @@
174182
<p>
175183
Base paragraph
176184
</p>
185+
177186
```
178187
179188
## Known issues

0 commit comments

Comments
 (0)