plugin ¤
MkDocs plugin that generates a Markdown file at the end of the build.
Classes:
-
MkdocsLLMsTxtPlugin
–The MkDocs plugin to generate an
llms.txt
file.
MkdocsLLMsTxtPlugin ¤
MkdocsLLMsTxtPlugin()
Bases: BasePlugin[PluginConfig]
The MkDocs plugin to generate an llms.txt
file.
This plugin defines the following event hooks:
on_page_content
on_post_build
Check the Developing Plugins page of mkdocs
for more information about its plugin system.
Methods:
-
on_config
–Save the global MkDocs configuration.
-
on_files
–Expand inputs for generated files.
-
on_page_content
–Record pages contents.
-
on_post_build
–Combine all recorded pages contents and convert it to a Markdown file with BeautifulSoup and Markdownify.
Source code in src/mkdocs_llmstxt/plugin.py
48 49 |
|
on_config ¤
on_config(config: MkDocsConfig) -> MkDocsConfig | None
Save the global MkDocs configuration.
Hook for the on_config
event. In this hook, we save the global MkDocs configuration into an instance variable, to re-use it later.
Parameters:
-
config
(MkDocsConfig
) –The MkDocs config object.
Returns:
-
MkDocsConfig | None
–The same, untouched config.
Source code in src/mkdocs_llmstxt/plugin.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
|
on_files ¤
on_files(
files: Files, *, config: MkDocsConfig
) -> Files | None
Expand inputs for generated files.
Hook for the on_files
event. In this hook we expand inputs for generated file (glob patterns using *
).
Parameters:
-
files
(Files
) –The collection of MkDocs files.
-
config
(MkDocsConfig
) –The MkDocs configuration.
Returns:
-
Files | None
–Modified collection or none.
Source code in src/mkdocs_llmstxt/plugin.py
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
|
on_page_content ¤
Record pages contents.
Hook for the on_page_content
event. In this hook we simply record the HTML of the pages into a dictionary whose keys are the pages' URIs.
Parameters:
-
html
(str
) –The rendered HTML.
-
page
(Page
) –The page object.
Source code in src/mkdocs_llmstxt/plugin.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
on_post_build ¤
on_post_build(config: MkDocsConfig, **kwargs: Any) -> None
Combine all recorded pages contents and convert it to a Markdown file with BeautifulSoup and Markdownify.
Hook for the on_post_build
event. In this hook we concatenate all previously recorded HTML, and convert it to Markdown using Markdownify.
Parameters:
-
config
(MkDocsConfig
) –MkDocs configuration.
Source code in src/mkdocs_llmstxt/plugin.py
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 |
|