Generate Python documentation in HTML.
__main__
special
¶
pydoc_fork A fork of pydoc that is optimized for generating html documentation in a CI context
Usage:
pydoc_fork
Options:
-h –help Show this screen.
-v –version Show version.
–quiet No printing or logging.
–verbose Crank up the logging.
–config
main()
¶
Get the args object from command parameters
Source code in pydoc_fork\__main__.py
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 |
|
commands
¶
Process commands as pure python functions.
All the CLI logic should be handled in main.
calculate_file_name(name, output_folder)
¶
Returns name. If this was written, what would its name be
Source code in pydoc_fork\commands.py
51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
document_directory(source_directory, output_folder, for_only='')
¶
Write out HTML documentation for all modules in a directory tree.
Source code in pydoc_fork\commands.py
142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 |
|
document_one(thing, output_folder, force_load=False)
¶
Write HTML documentation to a file in the current directory.
Source code in pydoc_fork\commands.py
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 |
|
modules_in_current()
¶
Convert . shortcut into list of modules
Source code in pydoc_fork\commands.py
67 68 69 70 71 72 73 74 75 76 77 |
|
process_path_or_dot_name(files, output_folder, overwrite_existing=False)
¶
Generate html documentation for all modules found at paths or dot notation module names.
- Parameters:
files:
List[str]
–output_folder:
str
–overwrite_existing:
bool
–
- Returns:
List[str]
– List of successfully documented modules
Source code in pydoc_fork\commands.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
|
write_docs_live_module(output_folder, total_third_party=0, skip_if_written=False)
¶
Write out HTML documentation for all modules in a directory tree.
Source code in pydoc_fork\commands.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
|
write_docs_per_module(modules, output_folder, skip_if_written=False)
¶
Write out HTML documentation for all modules in a directory tree.
Source code in pydoc_fork\commands.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
|
inspector
special
¶
This submodule has all the logic related to type-lookup and type-discovery. It has nothing to do with UI output other than it is creating a view model for the reporter submodule.
custom_types
¶
Custom Types so mypy can check the code
TypeLike (Protocol)
¶
This is a union of all sort of types
module_utils
¶
Module Manipulation
ImportTimeError (Exception)
¶
Errors that occurred while trying to import something to document it.
__init__(self, filename, exc_info)
special
¶
Set up
Source code in pydoc_fork\inspector\module_utils.py
26 27 28 29 30 |
|
__str__(self)
special
¶
For display
Source code in pydoc_fork\inspector\module_utils.py
32 33 34 35 |
|
importfile(path)
¶
Import a Python source file or compiled file given its path.
Source code in pydoc_fork\inspector\module_utils.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
|
ispackage(path)
¶
Guess whether a path refers to a package directory.
Source code in pydoc_fork\inspector\module_utils.py
124 125 126 127 128 129 130 |
|
locate(path, force_load=False)
¶
Locate an object by name or dotted path, importing as necessary.
Source code in pydoc_fork\inspector\module_utils.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
|
safe_import(path, force_load=False, cache={})
¶
Import a module; handle errors; return None if the module isn’t found.
If the module is found but an exception occurs, it’s wrapped in an ErrorDuringImport exception and reraised. Unlike import, if a package path is specified, the module at the end of the path is returned, not the package at the beginning. If the optional ‘force_load’ argument is True, we reload the module from disk (unless it’s a dynamic extension).
Source code in pydoc_fork\inspector\module_utils.py
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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
path_utils
¶
Path Manipulation
locate_file(file_name, executing_file)
¶
Find file relative to a source file, e.g. locate_file(“foo/bar.txt”, file)
Succeeds regardless to context of execution
Source code in pydoc_fork\inspector\path_utils.py
58 59 60 61 62 63 64 65 66 67 68 |
|
utils
¶
Unclassified utils
classify_class_attrs(the_object)
¶
Wrap inspect.classify_class_attrs, with fixup for data descriptors.
Source code in pydoc_fork\inspector\utils.py
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 |
|
classname(the_object, modname)
¶
Get a class name and qualify it with a module name if necessary.
Source code in pydoc_fork\inspector\utils.py
172 173 174 175 176 177 |
|
describe(thing)
¶
Produce a short description of the given thing.
Source code in pydoc_fork\inspector\utils.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
|
getdoc(the_object)
¶
Get the doc string or comments for an object.
Source code in pydoc_fork\inspector\utils.py
166 167 168 169 |
|
isdata(the_object)
¶
Check if an object is of a type that probably means it’s data.
Source code in pydoc_fork\inspector\utils.py
180 181 182 183 184 185 186 187 188 189 |
|
resolve(thing, force_load=False)
¶
Given an object or a path to an object, get the object and its name.
Source code in pydoc_fork\inspector\utils.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
|
sort_attributes(attrs, the_object)
¶
Sort the attrs list in-place by _fields and then alphabetically by name
Source code in pydoc_fork\inspector\utils.py
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 |
|
visiblename(name, all_things=None, obj=None)
¶
Decide whether to show documentation on a variable.
Source code in pydoc_fork\inspector\utils.py
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 |
|
reporter
special
¶
This module has everything that turns type info into html.
It also has a lot of type-lookup and type-discovery logic woven into into it, what we’d call a bad separation of concerns.
format_class
¶
Roughly a UI component for classes
classlink(the_object, modname)
¶
Make a link for a class.
Source code in pydoc_fork\reporter\format_class.py
26 27 28 29 30 31 |
|
docclass(the_object, name='', mod='', funcs=None, classes=None)
¶
Produce HTML documentation for a class object.
Source code in pydoc_fork\reporter\format_class.py
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 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
|
format_tree(tree, modname, parent=None)
¶
Creates a representation of class inheritance.
Source code in pydoc_fork\reporter\format_class.py
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
|
format_data
¶
Roughly a UI component for variables and their values
document_data(the_object, name='')
¶
Produce html documentation for a data descriptor.
Source code in pydoc_fork\reporter\format_data.py
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
|
format_module
¶
Roughly a UI component for modules
docmodule(the_object)
¶
Produce HTML documentation for a module object.
Source code in pydoc_fork\reporter\format_module.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
|
getdocloc(the_object, basedir='C:\\Users\\matth\\AppData\\Local\\Programs\\Python\\Python39\\Lib')
¶
Return the location of module docs or None
Source code in pydoc_fork\reporter\format_module.py
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 |
|
modulelink(the_object)
¶
Make a link for a module.
Source code in pydoc_fork\reporter\format_module.py
74 75 76 77 78 79 80 81 82 83 84 |
|
format_other
¶
Fallback docs
docother(the_object, name='')
¶
Produce HTML documentation for a data object.
Source code in pydoc_fork\reporter\format_other.py
8 9 10 11 12 13 14 |
|
format_page
¶
Roughly page and top level containers
document(the_object, name='', *args)
¶
Generate documentation for an object. This also part of the public API of class
Types of : Module, class, routine, data descriptor, “other” are supported
Modules ignore 1st name.
Public API doesn’t call with *args Args are: name, fdict, cdict (name twice?) mod, funcs, classes, mdict, the_object
Source code in pydoc_fork\reporter\format_page.py
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 |
|
index(directory, shadowed=None)
¶
Generate an HTML index for a directory of modules.
Source code in pydoc_fork\reporter\format_page.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
page(title, contents)
¶
Format an HTML page.
This is part of the public API
Source code in pydoc_fork\reporter\format_page.py
27 28 29 30 31 32 33 34 |
|
render(title, the_object, name)
¶
Compose two functions
Source code in pydoc_fork\reporter\format_page.py
22 23 24 |
|
format_routine
¶
Roughly a UI component for routines
docroutine(the_object, name='', mod='', funcs=None, classes=None, methods=None, class_object=None)
¶
Produce HTML documentation for a function or method object.
Source code in pydoc_fork\reporter\format_routine.py
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 95 96 97 98 99 100 101 102 103 |
|
formatter_html
¶
Roughly components
STDLIB_BASEDIR
¶
Formatter class for HTML documentation.
MarkupSyntax (Enum)
¶
Syntax type we assume comments are using
bigsection(title, fgcol, bgcol, contents, width=6, prelude='', marginalia='', gap=' ')
¶
Format a section with a big heading.
Source code in pydoc_fork\reporter\formatter_html.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
disabled_text(text)
¶
Wrap in grey
Source code in pydoc_fork\reporter\formatter_html.py
115 116 117 |
|
escape(value)
¶
HTML safe repr and escape
Source code in pydoc_fork\reporter\formatter_html.py
34 35 36 37 38 39 40 |
|
file_link(url, path)
¶
Make a link to source file.
Source code in pydoc_fork\reporter\formatter_html.py
149 150 151 |
|
heading(title, fgcol, bgcol, extras='')
¶
Format a page heading.
Source code in pydoc_fork\reporter\formatter_html.py
43 44 45 46 |
|
html_repr(value)
¶
Turn method into function
Source code in pydoc_fork\reporter\formatter_html.py
28 29 30 31 |
|
markup(text, funcs=None, classes=None, methods=None)
¶
Replace all linkable things with links of appropriate syntax.
Handle either an adhoc markup language, or RST or Markdown. funcs, classes, methods are name/symbol to URL maps.
Source code in pydoc_fork\reporter\formatter_html.py
162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 |
|
module_package_link(module_package_info)
¶
Make a link for a module or package to display in an index.
Source code in pydoc_fork\reporter\formatter_html.py
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
|
multicolumn(the_list, the_format, cols=4)
¶
Format a list of items into a multi-column list.
Source code in pydoc_fork\reporter\formatter_html.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
|
namelink(name, *dicts)
¶
Make a link for an identifier, given name-to-URL mappings.
Source code in pydoc_fork\reporter\formatter_html.py
120 121 122 123 124 125 126 |
|
preformat(text)
¶
Format literal preformatted text.
Source code in pydoc_fork\reporter\formatter_html.py
90 91 92 93 94 95 |
|
section(title, fgcol, bgcol, contents, width=6, prelude='', marginalia='', gap=' ')
¶
Format a section with a heading.
Source code in pydoc_fork\reporter\formatter_html.py
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
|
html_repr_class
¶
Class for safely making an HTML representation of a Python object.
HTMLRepr (Repr)
¶
Class for safely making an HTML representation of a Python object.
__init__(self)
special
¶
Some maximums
Source code in pydoc_fork\reporter\html_repr_class.py
13 14 15 16 17 18 |
|
escape(text)
staticmethod
¶
Simple html escaping
Source code in pydoc_fork\reporter\html_repr_class.py
21 22 23 24 25 26 27 |
|
repr(self, x)
¶
Delegates to Repr.repr
Source code in pydoc_fork\reporter\html_repr_class.py
29 30 31 |
|
repr1(self, x, level)
¶
Not sure, is dead code?
Source code in pydoc_fork\reporter\html_repr_class.py
33 34 35 36 37 38 39 |
|
repr_instance(self, x, level)
¶
Repr, but squash it into a window
Source code in pydoc_fork\reporter\html_repr_class.py
59 60 61 62 63 64 65 66 |
|
repr_str(self, x, _)
¶
Repr, but squash it into a window
Source code in pydoc_fork\reporter\html_repr_class.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
repr_string(self, x, _)
¶
Repr, but squash it into a window
Source code in pydoc_fork\reporter\html_repr_class.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
repr_unicode(self, x, _)
¶
Repr, but squash it into a window
Source code in pydoc_fork\reporter\html_repr_class.py
42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
inline_styles
¶
Style sheet for hardcoded styles
rst_support
¶
Rst to HTML function Credits: https://stackoverflow.com/a/49047197/33264
HTMLFragmentTranslator (HTMLTranslator)
¶
Minimum to call docutils
__init__(self, document)
special
¶
setup
Source code in pydoc_fork\reporter\rst_support.py
13 14 15 16 17 18 19 |
|
astext(self)
¶
minimum to call docutils
Source code in pydoc_fork\reporter\rst_support.py
21 22 23 |
|
rst_to_html(text)
¶
Convert rst string to html string
Source code in pydoc_fork\reporter\rst_support.py
30 31 32 |
|
string_utils
¶
String manipulation
cram(text, maximum_length)
¶
Omit part of a string if needed to make it fit in a maximum length.
Source code in pydoc_fork\reporter\string_utils.py
21 22 23 24 25 26 27 |
|
replace(text, *pairs)
¶
Do a series of global replacements on a string.
replace(“abc xyz”, “xyz”, “abc”) ‘abc abc’
Source code in pydoc_fork\reporter\string_utils.py
10 11 12 13 14 15 16 17 18 |
|
stripid(text)
¶
Remove the hexadecimal id from a Python object representation.
Source code in pydoc_fork\reporter\string_utils.py
33 34 35 36 |
|
settings
¶
Configuration options that could be used by anything.
Also global variables
PYTHONDOCS
¶
Module docs for core modules are assumed to be in
https://docs.python.org/X.Y/library/
This can be overridden by setting the PYTHONDOCS environment variable to a different URL or to a local directory containing the Library Reference Manual pages.
load_config(path)
¶
Copy config from toml to globals
Source code in pydoc_fork\settings.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
|
parse_toml(path_string)
¶
Parse toml
Source code in pydoc_fork\settings.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|