mkdocs_llmstxt ¤
mkdocs-llmstxt package.
MkDocs plugin to generate an /llms.txt file.
Classes:
-
MkdocsLLMsTxtPlugin
–The MkDocs plugin to generate an
llms.txt
file.
Functions:
-
autoclean
–Auto-clean the soup by removing elements.
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
–Convert page content into a Markdown file and save the result to be processed in the
on_post_build
hook. -
on_post_build
–Create the final
llms.txt
file and the MD files for all selected pages.
Attributes:
-
md_pages
(dict[str, list[_MDPageInfo]]
) –Dictionary mapping section names to a list of page infos.
-
mkdocs_config
(MkDocsConfig
) –The global MkDocs configuration.
md_pages instance-attribute
¤
Dictionary mapping section names to a list of page infos.
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/_internal/plugin.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
|
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/_internal/plugin.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 |
|
on_page_content ¤
Convert page content into a Markdown file and save the result to be processed in the on_post_build
hook.
Hook for the on_page_content
event.
Parameters:
-
html
(str
) –The rendered HTML.
-
page
(Page
) –The page object.
Source code in src/mkdocs_llmstxt/_internal/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 |
|
on_post_build ¤
on_post_build(
*, config: MkDocsConfig, **kwargs: Any
) -> None
Create the final llms.txt
file and the MD files for all selected pages.
Hook for the on_post_build
event.
Parameters:
-
config
(MkDocsConfig
) –MkDocs configuration.
Source code in src/mkdocs_llmstxt/_internal/plugin.py
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 |
|
autoclean ¤
autoclean(soup: BeautifulSoup) -> None
Auto-clean the soup by removing elements.
Parameters:
-
soup
(BeautifulSoup
) –The soup to modify.
Source code in src/mkdocs_llmstxt/_internal/preprocess.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
|