Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

A little something I created a little while back while learning to develop MkDocs Plugins and Markdown Extensions. If you think it's useful, feel free to add it to the doc pages or wherever you think is best.

flowchart TB
  subgraph Build[ ]
    subgraph Launch
      direction LR
      subgraph load_config["Load Configuration (YAML)"]
        direction TB
        me(Load Markdown Extensions) -->
        mec(Load Markdown Extensions Configs) -->
        Plugins(Load Plugins) -->
        Hooks(Load Hooks)
      end

      load_config -->
      on_startup -->
      on_config -->
      on_pre_build -->
      on_files -->
      on_nav
    end

    subgraph populate_pages[Populate Each Page]
      direction LR
      on_pre_page -->
      on_page_read_source -->
      on_page_markdown --> page.render

      subgraph page.render["Python Markdown (Markdown to HTML)"]
        direction TB
        me2(Load Markdown Extensions) -->
        mec2(Load Markdown Extensions Configs) -->
        preprocessors("Run Extensions' preprocessor") -->
        blockparser("Run Extensions' blockparser") -->
        treeprocessors("Run Extensions' treeprocessor") -->
        postprocessors("Run Extensions' postprocessor") 
      end

      page.render -->
      on_page_content
    end

    subgraph build_markdown_pages[Build Each Page]
      on_page_context -->
      render_template[/"Render Template (Jinja2)"/] -->
      on_post_page
    end

    subgraph build_templates[Build Each Template]
      on_pre_template -->
      on_template_context -->
      on_post_template
    end

    build_templates -.- build_theme_templates
    build_templates -.- build_extra_templates

    Launch -->
    populate_pages -->
    on_env -->
    copy_static_files(Copy Files to Destination) -->
    build_theme_templates(Build Theme Templates) -->
    build_extra_templates(Build Extra Templates) -->
    build_markdown_pages
  end
  build_markdown_pages -->
  validate_anchor_links -->
  on_post_build -- "<code>mkdocs build</code>" -->
  on_shutdown

  on_post_build -- "<code>mkdocs serve</code>" -->
  on_serve -- "terminate processes" -->
  on_shutdown
  on_serve -- "On File Change" --> Launch

  on_build_error["If Error (Exception) encountered:\non_build_error"]

  %% Build subgraph is just to prevent the 'on_serve' to 'Launch' link
  %% from changing the order of the diagram, so we use styling to hide it.
  style Build fill:#fff0, stroke:#fff0
Loading
``` mermaid
flowchart TB
  subgraph Build[ ]
    subgraph Launch
      direction LR
      subgraph load_config["Load Configuration (YAML)"]
        direction TB
        me(Load Markdown Extensions) -->
        mec(Load Markdown Extensions Configs) -->
        Plugins(Load Plugins) -->
        Hooks(Load Hooks)
      end

      load_config -->
      on_startup -->
      on_config -->
      on_pre_build -->
      on_files -->
      on_nav
    end

    subgraph populate_pages[Populate Each Page]
      direction LR
      on_pre_page -->
      on_page_read_source -->
      on_page_markdown --> page.render

      subgraph page.render["Python Markdown (Markdown to HTML)"]
        direction TB
        me2(Load Markdown Extensions) -->
        mec2(Load Markdown Extensions Configs) -->
        preprocessors("Run Extensions' preprocessor") -->
        blockparser("Run Extensions' blockparser") -->
        treeprocessors("Run Extensions' treeprocessor") -->
        postprocessors("Run Extensions' postprocessor") 
      end

      page.render -->
      on_page_content
    end

    subgraph build_markdown_pages[Build Each Page]
      on_page_context -->
      render_template[/"Render Template (Jinja2)"/] -->
      on_post_page
    end

    subgraph build_templates[Build Each Template]
      on_pre_template -->
      on_template_context -->
      on_post_template
    end

    build_templates -.- build_theme_templates
    build_templates -.- build_extra_templates

    Launch -->
    populate_pages -->
    on_env -->
    copy_static_files(Copy Files to Destination) -->
    build_theme_templates(Build Theme Templates) -->
    build_extra_templates(Build Extra Templates) -->
    build_markdown_pages
  end
  build_markdown_pages -->
  validate_anchor_links -->
  on_post_build -- "<code>mkdocs build</code>" -->
  on_shutdown

  on_post_build -- "<code>mkdocs serve</code>" -->
  on_serve -- "terminate processes" -->
  on_shutdown
  on_serve -- "On File Change" --> Launch

  on_build_error["If Error (Exception) encountered:\non_build_error"]

  %% Build subgraph is just to prevent the 'on_serve' to 'Launch' link
  %% from changing the order of the diagram, so we use styling to hide it.
  style Build fill:#fff0, stroke:#fff0
```
You must be logged in to vote

Replies: 1 comment

Comment options

Nice! Have you seen https://www.mkdocs.org/dev-guide/plugins/#events (collapsed diagram)?

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.