Build
Build site.
build(options)
Build the site.
Source code in mccole/build.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 | |
_build_page(config, env, slug, src_path, ix_entries=None, template_name=TEMPLATE_PAGE)
Handle a Markdown file.
Source code in mccole/build.py
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 | |
_build_index_page(config, env, ix_entries)
Build the index page from collected ix_entries.
Source code in mccole/build.py
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | |
_build_other(config, src_path)
Handle non-Markdown file.
Source code in mccole/build.py
118 119 120 121 | |
_collect_element_numbers(dst_path, doc, selector, prefix, kind, get_caption_node, labeler)
Number figure-like elements and return IDs.
Source code in mccole/build.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
_collect_figure_numbers(dst_path, doc)
Number figures and return IDs.
Source code in mccole/build.py
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
_collect_table_numbers(dst_path, doc)
Number tables and return IDs.
Source code in mccole/build.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 | |
_fill_element_numbers(dst_path, doc, prefix, known, text)
Fill in cross-reference numbers.
Source code in mccole/build.py
195 196 197 198 199 200 201 202 203 204 205 206 | |
_find_files(config)
Find section files and other files.
Source code in mccole/build.py
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 | |
_is_interesting_file(config, excludes, skip_patterns, filepath)
Is this file worth copying over?
Source code in mccole/build.py
241 242 243 244 245 246 247 248 249 250 | |
_load_configuration(options)
Load configuration and combine with options.
Source code in mccole/build.py
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 | |
_load_book_repo(src_path, home_page)
Extract the '[repo]' link from the home page.
Source code in mccole/build.py
303 304 305 306 307 308 309 310 | |
_load_book_title(src_path, home_page)
Extract the H1 title from the home page as the book title.
Source code in mccole/build.py
313 314 315 316 317 318 319 320 | |
_load_glossary(src_path)
Load glossary keys and terms.
Source code in mccole/build.py
323 324 325 326 327 328 | |
_render_page(config, env, slug, src_path, dst_path, raw_html, metadata, template_name)
Render, patch, and write one page.
Source code in mccole/build.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 | |
_fragment_patchers()
Patchers safe to run before link-rewriting and numbering (used by single-page build).
Source code in mccole/build.py
349 350 351 352 353 354 355 356 357 358 359 360 | |
_page_patchers()
Return the ordered list of DOM patch functions.
Source code in mccole/build.py
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
_build_page_fragment(config, env, slug, src_path, ix_entries=None)
Build a page and return (metadata, dst_path, doc) without writing or link-patching.
Source code in mccole/build.py
382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
_make_context(config, slug, metadata=None)
Make rendering context for a particular file.
Source code in mccole/build.py
408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 | |
_make_output_path(config, src_path, suffix=None)
Generate output file path.
Source code in mccole/build.py
471 472 473 474 475 476 477 478 479 480 481 482 | |
_make_root_prefix(config, path)
Create prefix to root for path.
Source code in mccole/build.py
485 486 487 488 489 490 | |
_patch_bibliography_links(config, src_path, dst_path, doc)
Convert b: bibliography links.
Source code in mccole/build.py
493 494 495 | |
_patch_figure_numbers(config, src_path, dst_path, doc)
Insert figure numbers.
Source code in mccole/build.py
498 499 500 501 | |
_patch_glossary_links(config, src_path, dst_path, doc)
Convert g: glossary links.
Source code in mccole/build.py
504 505 506 | |
_patch_markdown_attribute(config, src_path, dst_path, doc)
Remove markdown='1' attribute.
Source code in mccole/build.py
509 510 511 512 | |
_patch_exercise_labels(config, src_path, dst_path, doc)
Add aria-label to exercise sections so screen reader landmark navigation works.
Source code in mccole/build.py
515 516 517 518 519 | |
_patch_pre_accessibility(config, src_path, dst_path, doc)
Make scrollable
blocks keyboard-focusable and label them with their language.
Source code in mccole/build.py
522
523
524
525
526
527
528
529
530
531
def _patch_pre_accessibility(config, src_path, dst_path, doc):
"""Make scrollable <pre> blocks keyboard-focusable and label them with their language."""
for node in doc.select("pre"):
node["tabindex"] = "0"
# Extract language from class like "language-python" → "python"
classes = node.get("class", [])
for cls in classes:
if cls.startswith("language-"):
node["data-lang"] = cls[len("language-") :]
break
_patch_pre_code_classes(config, src_path, dst_path, doc)
Add language classes to
elements.
Source code in mccole/build.py
534
535
536
537
538
def _patch_pre_code_classes(config, src_path, dst_path, doc):
"""Add language classes to <pre> elements."""
for node in doc.select("pre>code"):
cls = node.get("class", [])
node.parent["class"] = node.parent.get("class", []) + cls
_patch_th_scope(config, src_path, dst_path, doc)
Add scope attributes to
Source code in mccole/build.py
541 542 543 544 545 546 547 548 | |
_patch_root_links(config, src_path, dst_path, doc)
Convert @ links to relative path to root.
Source code in mccole/build.py
551 552 553 554 555 556 557 558 559 560 561 562 563 | |
_patch_special_link(config, src_path, dst_path, doc, prefix, stem, change_text)
Patch specially-prefixed links.
Source code in mccole/build.py
566 567 568 569 570 571 572 573 574 575 | |
_patch_table_numbers(config, src_path, dst_path, doc)
Insert figure numbers.
Source code in mccole/build.py
578 579 580 581 | |
_patch_terms_defined(config, src_path, dst_path, doc)
Insert terms defined where requested.
Source code in mccole/build.py
584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 | |
_patch_title(config, src_path, dst_path, doc)
Make sure the HTML title element is set.
Source code in mccole/build.py
615 616 617 618 619 620 621 622 623 624 625 626 | |