@@ -81,19 +81,21 @@ by introducing syntax for docstrings for variables.
8181following the normal class inheritance patterns.
8282Consider the following code example:
8383
84- >>> class A:
85- ... def test(self):
86- ... """Docstring for A."""
87- ... pass
88- ...
89- >>> class B(A):
90- ... def test(self):
91- ... pass
92- ...
93- >>> A.test.__doc__
94- 'Docstring for A.'
95- >>> B.test.__doc__
96- None
84+ ``` python-repl
85+ >>> class A:
86+ ... def test(self):
87+ ... """Docstring for A."""
88+ ... pass
89+ ...
90+ >>> class B(A):
91+ ... def test(self):
92+ ... pass
93+ ...
94+ >>> A.test.__doc__
95+ 'Docstring for A.'
96+ >>> B.test.__doc__
97+ None
98+ ```
9799
98100In Python, the docstring for ` B.test ` doesn't exist, even though a
99101docstring was defined for ` A.test ` .
@@ -115,18 +117,20 @@ For example:
115117
116118[ PEP-224 ] : http://www.python.org/dev/peps/pep-0224
117119
118- module_variable = 1
119- """PEP 224 docstring for module_variable."""
120+ ``` python
121+ module_variable = 1
122+ """ PEP 224 docstring for module_variable."""
120123
121- class C:
122- #: Documentation comment for class_variable
123- #: spanning over three lines.
124- class_variable = 2 #: Assignment line is included.
124+ class C :
125+ # : Documentation comment for class_variable
126+ # : spanning over three lines.
127+ class_variable = 2 # : Assignment line is included.
125128
126- def __init__(self):
127- #: Instance variable's doc-comment
128- self.variable = 3
129- """But note, PEP 224 docstrings take precedence."""
129+ def __init__ (self ):
130+ # : Instance variable's doc-comment
131+ self .variable = 3
132+ """ But note, PEP 224 docstrings take precedence."""
133+ ```
130134
131135While the resulting variables have no ` __doc__ ` attribute,
132136` pdoc ` compensates by reading the source code (when available)
@@ -162,12 +166,14 @@ This feature is useful when there's no feasible way of
162166attaching a docstring to something. A good example is a
163167[ namedtuple] ( https://docs.python.org/3/library/collections.html#collections.namedtuple ) :
164168
165- __pdoc__ = {}
169+ ``` python
170+ __pdoc__ = {}
166171
167- Table = namedtuple('Table', ['types', 'names', 'rows'])
168- __pdoc__['Table.types'] = 'Types for each column in the table.'
169- __pdoc__['Table.names'] = 'The names of each column in the table.'
170- __pdoc__['Table.rows'] = 'Lists corresponding to each row in the table.'
172+ Table = namedtuple(' Table' , [' types' , ' names' , ' rows' ])
173+ __pdoc__[' Table.types' ] = ' Types for each column in the table.'
174+ __pdoc__[' Table.names' ] = ' The names of each column in the table.'
175+ __pdoc__[' Table.rows' ] = ' Lists corresponding to each row in the table.'
176+ ```
171177
172178` pdoc ` will then show ` Table ` as a class with documentation for the
173179` types ` , ` names ` and ` rows ` members.
@@ -234,7 +240,7 @@ the identifier name must be fully qualified, for example
234240` pdoc.Doc.docstring ` ) while <code >\` Doc.docstring\` </code >
235241only works within ` pdoc ` module.
236242
237- [ backticks ] : https://en.wikipedia.org/wiki/Grave_accent#Use_in_programming
243+ [ backticks ] : https://en.wikipedia.org/wiki/Backtick
238244
239245
240246Command-line interface
@@ -246,32 +252,42 @@ For example, to produce HTML documentation of your whole package
246252in subdirectory 'build' of the current directory, using the default
247253HTML template, run:
248254
249- $ pdoc --html --output-dir build my_package
255+ ``` shell
256+ $ pdoc --html --output-dir build my_package
257+ ```
250258
251259If you want to omit the source code preview, run:
252260
253- $ pdoc --html --config show_source_code=False my_package
261+ ``` shell
262+ $ pdoc --html --config show_source_code=False my_package
263+ ```
254264
255265Find additional template configuration tunables in [ custom templates]
256266section below.
257267
258268To run a local HTTP server while developing your package or writing
259269docstrings for it, run:
260270
261- $ pdoc --http : my_package
271+ ``` shell
272+ $ pdoc --http : my_package
273+ ```
262274
263275To re-build documentation as part of your continuous integration (CI)
264276best practice, i.e. ensuring all reference links are correct and
265277up-to-date, make warnings error loudly by settings the environment
266278variable [ ` PYTHONWARNINGS ` ] [ PYTHONWARNINGS ] before running pdoc:
267279
268- $ export PYTHONWARNINGS='error::UserWarning'
280+ ``` shell
281+ $ export PYTHONWARNINGS=' error::UserWarning'
282+ ```
269283
270284[ PYTHONWARNINGS ] : https://docs.python.org/3/using/cmdline.html#envvar-PYTHONWARNINGS
271285
272286For brief usage instructions, type:
273287
274- $ pdoc --help
288+ ``` shell
289+ $ pdoc --help
290+ ```
275291
276292Even more usage examples can be found in the [ FAQ] .
277293
@@ -292,23 +308,25 @@ Afterwards, you can use `pdoc.Module.html` and `pdoc.Module.text`
292308methods to output documentation in the desired format.
293309For example:
294310
295- import pdoc
311+ ``` python
312+ import pdoc
296313
297- modules = ['a', 'b'] # Public submodules are auto-imported
298- context = pdoc.Context()
314+ modules = [' a' , ' b' ] # Public submodules are auto-imported
315+ context = pdoc.Context()
299316
300- modules = [pdoc.Module(mod, context=context)
301- for mod in modules]
302- pdoc.link_inheritance(context)
317+ modules = [pdoc.Module(mod, context = context)
318+ for mod in modules]
319+ pdoc.link_inheritance(context)
303320
304- def recursive_htmls(mod):
305- yield mod.name, mod.html()
306- for submod in mod.submodules():
307- yield from recursive_htmls(submod)
321+ def recursive_htmls (mod ):
322+ yield mod.name, mod.html()
323+ for submod in mod.submodules():
324+ yield from recursive_htmls(submod)
308325
309- for mod in modules:
310- for module_name, html in recursive_htmls(mod):
311- ... # Process
326+ for mod in modules:
327+ for module_name, html in recursive_htmls(mod):
328+ ... # Process
329+ ```
312330
313331When documenting a single module, you might find
314332functions ` pdoc.html ` and ` pdoc.text ` handy.
0 commit comments