report
Base class for the whole report.
This corresponds to a mkdocs project. The class is mainly responsible for creating a mkdocs project if it doesn't exist already and ensuring that the neccessary settings are all included.
Report
Class representing a report.
Source code in mkreports/report.py
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 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 |
|
__init__(path=None, project_root=None, md_defaults=None)
Initialize the report object. This relies on the report folder already existing, including necessary files for mkdocs. If this is not the case, use the create class-method.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Optional[Union[str, Path]]
|
Path to the top-level directory of the report. |
None
|
project_root |
Optional[Union[str, Path]]
|
Directory that is the root of the project. If None, tries to use the root of the git-repository if there is one. Otherwise uses the root of the file-system. |
None
|
md_defaults |
Optional[Dict[str, Dict[str, Any]]
|
A dictionary mapping the names md objects (accessed from the proxy) to default keywords included when they are being called. |
None
|
Source code in mkreports/report.py
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 |
|
create(path, report_name, project_root=None, md_defaults=None, settings=default_settings, exist_ok=False)
Create a new report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Union[str, Path]
|
Top-level folder of the report. |
required |
report_name |
str
|
Name of the report (mkdocs site-name) |
required |
project_root |
Optional[Union[str, Path]]
|
Directory that is the root of the project. If None, tries to use the root of the git-repository if there is one. Otherwise uses the root of the file-system. |
None
|
md_defaults |
Optional[Dict[str, Dict[str, Any]]
|
A dictionary mapping the names md objects (accessed from the proxy) to default keywords included when they are being called. |
None
|
settings |
Optional[Mapping[str, str]]
|
Settings of the report. |
default_settings
|
exist_ok |
bool
|
Is it ok if it already exists? |
False
|
Returns:
Name | Type | Description |
---|---|---|
Report |
'Report'
|
An instance of the class representing the project. |
Source code in mkreports/report.py
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 |
|
docs_dir()
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Docs-folder in the report. |
Source code in mkreports/report.py
158 159 160 161 162 163 164 165 |
|
get_nav_entry(path)
Get the NavEntry for a specific page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path |
Path
|
Path to the page, absolute or relative to docs_dir. |
required |
Returns:
Type | Description |
---|---|
Optional[NavEntry]
|
The NavEntry if it exists or None. |
Source code in mkreports/report.py
263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 |
|
index_file()
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Location of the index file. |
Source code in mkreports/report.py
167 168 169 170 171 172 173 174 |
|
insert_page(path_target, path_source, mode='TS')
Insert a page into the report.
This function can take an existing page (can also just be a markdown file) and inserts it into the page.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path_source |
Path
|
The file to insert. Expected to be a markdown file. |
required |
path_target |
Union[Path, NavEntry]
|
Path or NavEntry where the page should be inserted. |
required |
mode |
Literal['S', 'T', 'ST', 'TS']
|
Insertion mode. If 'S', then only the target is overwritten with the source. If 'T', then the target is left as is, if it exists. For 'ST', the source is prepended, for 'TS', the source is appended to the target. |
'TS'
|
Source code in mkreports/report.py
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 |
|
javascript_path()
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Location of the javascript folder. |
Source code in mkreports/report.py
176 177 178 179 180 181 182 183 |
|
mkdocs_file()
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Location of the mkdocs file. |
Source code in mkreports/report.py
149 150 151 152 153 154 155 156 |
|
page(page_name, truncate=False, add_bottom=True, md_defaults=None)
Create a page in the report.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
page_name |
Union[NavEntry, Path, str]
|
Name of the page and path. Using a NavEntry, a custom nav-entry and path can be specified. The path is always relative to the report-docs directory. |
required |
truncate |
bool
|
Should the page be truncated if it exists? Also deletes the store_path. |
False
|
add_bottom |
bool
|
Should new entries be added at the bottom or at the top of the page. Top of the page is used for IPython. |
True
|
md_defaults |
Optional[Dict[str, Dict[str, Any]]
|
A dictionary mapping the names md objects (accessed from the proxy) to default keywords included when they are being called. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Page |
'Page'
|
An object representing a new page. |
Source code in mkreports/report.py
290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
path()
Returns:
Name | Type | Description |
---|---|---|
Path |
Path
|
Path object that is the top-level of the report. |
Source code in mkreports/report.py
141 142 143 144 145 146 147 |
|
normalize_nav_entry(nav_entry)
Normalize a nav entry
Ensures that if a string or Path is given, is turned into a NavEntry.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
nav_entry |
Union[str, Path, NavEntry]
|
The str, path or nav_entry to use. |
required |
Source code in mkreports/report.py
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 |
|