def _populate_page(page: Page, config: MkDocsConfig, files: Files, dirty: bool = False) -> None:
    """Read page content from docs_dir and render Markdown."""
    config._current_page = page
    try:
        # When --dirty is used, only read the page if the file has been modified since the
        # previous build of the output.
        if dirty and not page.file.is_modified():
            return

        # Run the `pre_page` plugin event
        page = config.plugins.on_pre_page(page, config=config, files=files)

        page.read_source(config)
        assert page.markdown is not None

        # Run `page_markdown` plugin events.
        page.markdown = config.plugins.on_page_markdown(
            page.markdown, page=page, config=config, files=files
        )

        page.render(config, files)
        assert page.content is not None

        # Run `page_content` plugin events.
        page.content = config.plugins.on_page_content(
            page.content, page=page, config=config, files=files
        )
    except Exception as e:
        message = f"Error reading page '{page.file.src_uri}':"
        # Prevent duplicated the error message because it will be printed immediately afterwards.
        if not isinstance(e, BuildError):
            message += f" {e}"
        log.error(message)
        raise
    finally:
        config._current_page = None
Read page content from docs_dir and render Markdown.
mkdocs/commands/build.py