Exemplo n.º 1
0
    def on_config(self, config):
        # Theme
        config['theme'] = Theme(name="material")

        # Plugins
        del config['plugins']['techdocs-core']

        search_plugin = SearchPlugin()
        search_plugin.load_config({})
        config['plugins']['search'] = search_plugin

        return config
Exemplo n.º 2
0
    def dump_search_files(self) -> None:
        indexer = self.templates.translator.indexer

        # HACK: Yes, I felt dirty after writing this.
        plugin = MkDocsSearchPlugin()
        plugin.search_index = indexer
        plugin.config = indexer.config

        try:
            plugin.on_post_build(indexer.config)
        except ZeroDivisionError:
            raise Exception(
                "FATAL (sphinx-mkdocs-theme): Document URLs are incorrect.")
Exemplo n.º 3
0
    def on_config(self, config):
        # Theme
        config["theme"] = Theme(name="material")

        # Plugins
        del config["plugins"]["techdocs-core"]

        search_plugin = SearchPlugin()
        search_plugin.load_config({})

        monorepo_plugin = MonorepoPlugin()
        monorepo_plugin.load_config({})

        config["plugins"]["search"] = search_plugin
        config["plugins"]["monorepo"] = monorepo_plugin

        search_plugin = SearchPlugin()
        search_plugin.load_config({})
        config["plugins"]["search"] = search_plugin

        # Markdown Extensions
        config["markdown_extensions"].append("admonition")
        config["markdown_extensions"].append("abbr")
        config["markdown_extensions"].append("attr_list")
        config["markdown_extensions"].append("def_list")
        config["markdown_extensions"].append("codehilite")
        config["mdx_configs"]["codehilite"] = {
            "linenums": True,
            "guess_lang": False,
            "pygments_style": "friendly",
        }
        config["markdown_extensions"].append("toc")
        config["mdx_configs"]["toc"] = {
            "permalink": True,
        }
        config["markdown_extensions"].append("footnotes")
        config["markdown_extensions"].append("markdown.extensions.tables")
        config["markdown_extensions"].append("pymdownx.betterem")
        config["mdx_configs"]["pymdownx.betterem"] = {
            "smart_enable": "all",
        }
        config["markdown_extensions"].append("pymdownx.caret")
        config["markdown_extensions"].append("pymdownx.critic")
        config["markdown_extensions"].append("pymdownx.details")
        config["markdown_extensions"].append("pymdownx.emoji")
        config["mdx_configs"]["pymdownx.emoji"] = {
            "emoji_generator": "!!python/name:pymdownx.emoji.to_svg",
        }
        config["markdown_extensions"].append("pymdownx.inlinehilite")
        config["markdown_extensions"].append("pymdownx.magiclink")
        config["markdown_extensions"].append("pymdownx.mark")
        config["markdown_extensions"].append("pymdownx.smartsymbols")
        config["markdown_extensions"].append("pymdownx.superfences")
        config["markdown_extensions"].append("pymdownx.tasklist")
        config["mdx_configs"]["pymdownx.tasklist"] = {
            "custom_checkbox": True,
        }
        config["markdown_extensions"].append("pymdownx.tilde")

        return config
Exemplo n.º 4
0
    def on_config(self, config):
        # Theme
        config["theme"] = Theme(name="material")

        # Plugins
        del config["plugins"]["techdocs-core"]

        search_plugin = SearchPlugin()
        search_plugin.load_config({})

        monorepo_plugin = MonorepoPlugin()
        monorepo_plugin.load_config({})

        config["plugins"]["search"] = search_plugin
        config["plugins"]["monorepo"] = monorepo_plugin

        search_plugin = SearchPlugin()
        search_plugin.load_config({})
        config["plugins"]["search"] = search_plugin

        # Markdown Extensions
        config['markdown_extensions'].append('admonition')
        config['markdown_extensions'].append('abbr')
        config['markdown_extensions'].append('attr_list')
        config['markdown_extensions'].append('def_list')
        config['markdown_extensions'].append('codehilite')
        config['mdx_configs']['codehilite'] = {
            'linenums': True,
            'guess_lang': False,
            'pygments_style': 'friendly',
        }
        config['markdown_extensions'].append('toc')
        config['mdx_configs']['toc'] = {
            'permalink': True,
        }
        config['markdown_extensions'].append('footnotes')
        config['markdown_extensions'].append('markdown.extensions.tables')
        config['markdown_extensions'].append('pymdownx.betterem')
        config['mdx_configs']['pymdownx.betterem'] = {
            'smart_enable': 'all',
        }
        config['markdown_extensions'].append('pymdownx.caret')
        config['markdown_extensions'].append('pymdownx.critic')
        config['markdown_extensions'].append('pymdownx.details')
        config['markdown_extensions'].append('pymdownx.emoji')
        config['mdx_configs']['pymdownx.emoji'] = {
            'emoji_generator': '!!python/name:pymdownx.emoji.to_svg',
        }
        config['markdown_extensions'].append('pymdownx.inlinehilite')
        config['markdown_extensions'].append('pymdownx.magiclink')
        config['markdown_extensions'].append('pymdownx.mark')
        config['markdown_extensions'].append('pymdownx.smartsymbols')
        config['markdown_extensions'].append('pymdownx.superfences')
        config['markdown_extensions'].append('pymdownx.tasklist')
        config['mdx_configs']['pymdownx.tasklist'] = {
            'custom_checkbox': True,
        }
        config['markdown_extensions'].append('pymdownx.tilde')

        return config
Exemplo n.º 5
0
    def on_config(self, config):
        # Theme
        config["theme"] = Theme(name="material")

        # Plugins
        del config["plugins"]["techdocs-core"]

        search_plugin = SearchPlugin()
        search_plugin.load_config({})

        monorepo_plugin = MonorepoPlugin()
        monorepo_plugin.load_config({})

        config["plugins"]["search"] = search_plugin
        config["plugins"]["monorepo"] = monorepo_plugin

        search_plugin = SearchPlugin()
        search_plugin.load_config({})
        config["plugins"]["search"] = search_plugin

        return config
Exemplo n.º 6
0
    def on_config(self, config):
        with open(
                os.path.join(self.tmp_dir_techdocs_theme.name,
                             "techdocs_metadata.json"),
                "w+",
        ) as fp:
            fp.write(
                '{{ {"site_name": (config.site_name | string), '
                '"site_description": (config.site_description | string)} | tojson }}'
            )

        mdx_configs_override = {}
        if "mdx_configs" in config:
            mdx_configs_override = config["mdx_configs"].copy()

        # Theme
        if config["theme"].name != TECHDOCS_DEFAULT_THEME:
            config["theme"] = Theme(name=TECHDOCS_DEFAULT_THEME)
        elif config["theme"].name == TECHDOCS_DEFAULT_THEME:
            log.info(
                "[mkdocs-techdocs-core] Overridden '%s' theme settings in use",
                TECHDOCS_DEFAULT_THEME,
            )

        config["theme"].static_templates.update({"techdocs_metadata.json"})
        config["theme"].dirs.append(self.tmp_dir_techdocs_theme.name)

        # Plugins
        del config["plugins"]["techdocs-core"]

        search_plugin = SearchPlugin()
        search_plugin.load_config({})

        monorepo_plugin = MonorepoPlugin()
        monorepo_plugin.load_config({})
        config["plugins"]["search"] = search_plugin
        config["plugins"]["monorepo"] = monorepo_plugin

        # Markdown Extensions
        if "markdown_extensions" not in config:
            config["markdown_extensions"] = []

        if "mdx_configs" not in config:
            config["mdx_configs"] = {}

        config["markdown_extensions"].append("admonition")
        config["markdown_extensions"].append("toc")
        config["mdx_configs"]["toc"] = {
            "permalink": True,
        }

        config["markdown_extensions"].append("pymdownx.caret")
        config["markdown_extensions"].append("pymdownx.critic")
        config["markdown_extensions"].append("pymdownx.details")
        config["markdown_extensions"].append("pymdownx.emoji")
        config["mdx_configs"]["pymdownx.emoji"] = {"emoji_generator": to_svg}
        config["markdown_extensions"].append("pymdownx.inlinehilite")
        config["markdown_extensions"].append("pymdownx.magiclink")
        config["markdown_extensions"].append("pymdownx.mark")
        config["markdown_extensions"].append("pymdownx.smartsymbols")
        config["markdown_extensions"].append("pymdownx.superfences")
        config["markdown_extensions"].append("pymdownx.highlight")
        config["mdx_configs"]["pymdownx.highlight"] = {
            "linenums": True,
            "pygments_lang_class": True,
        }
        config["markdown_extensions"].append("pymdownx.extra")
        config["mdx_configs"]["pymdownx.betterem"] = {
            "smart_enable": "all",
        }
        config["markdown_extensions"].append("pymdownx.tabbed")
        config["mdx_configs"]["pymdownx.tabbed"] = {
            "alternate_style": True,
        }
        config["markdown_extensions"].append("pymdownx.tasklist")
        config["mdx_configs"]["pymdownx.tasklist"] = {
            "custom_checkbox": True,
        }
        config["markdown_extensions"].append("pymdownx.tilde")

        config["markdown_extensions"].append("markdown_inline_graphviz")
        config["markdown_extensions"].append("plantuml_markdown")
        config["markdown_extensions"].append("mdx_truly_sane_lists")

        # merge config supplied by user in the mkdocs.yml
        for key in mdx_configs_override:
            if key in config["mdx_configs"]:
                default_config = config["mdx_configs"][key]
                override_config = mdx_configs_override[key]
                default_config.update(override_config)

        return config
Exemplo n.º 7
0
    def on_config(self, config):
        fp = open(
            os.path.join(tempfile.gettempdir(), "techdocs_metadata.json"),
            "w+")
        fp.write(
            '{\n  "site_name": "{{ config.site_name }}",\n  "site_description": "{{ config.site_description }}"\n}'
        )

        # Theme
        config["theme"] = Theme(
            name="material",
            static_templates=[
                "techdocs_metadata.json",
            ],
        )
        config["theme"].dirs.append(tempfile.gettempdir())

        # Plugins
        del config["plugins"]["techdocs-core"]

        search_plugin = SearchPlugin()
        search_plugin.load_config({})

        monorepo_plugin = MonorepoPlugin()
        monorepo_plugin.load_config({})

        config["plugins"]["search"] = search_plugin
        config["plugins"]["monorepo"] = monorepo_plugin

        search_plugin = SearchPlugin()
        search_plugin.load_config({})
        config["plugins"]["search"] = search_plugin

        # Markdown Extensions
        config["markdown_extensions"].append("admonition")
        config["markdown_extensions"].append("abbr")
        config["markdown_extensions"].append("attr_list")
        config["markdown_extensions"].append("def_list")
        config["markdown_extensions"].append("codehilite")
        config["mdx_configs"]["codehilite"] = {
            "linenums": True,
            "guess_lang": False,
            "pygments_style": "friendly",
        }
        config["markdown_extensions"].append("toc")
        config["mdx_configs"]["toc"] = {
            "permalink": True,
        }
        config["markdown_extensions"].append("footnotes")
        config["markdown_extensions"].append("markdown.extensions.tables")
        config["markdown_extensions"].append("pymdownx.betterem")
        config["mdx_configs"]["pymdownx.betterem"] = {
            "smart_enable": "all",
        }
        config["markdown_extensions"].append("pymdownx.caret")
        config["markdown_extensions"].append("pymdownx.critic")
        config["markdown_extensions"].append("pymdownx.details")
        config["markdown_extensions"].append("pymdownx.emoji")
        config["mdx_configs"]["pymdownx.emoji"] = {"emoji_generator": to_svg}
        config["markdown_extensions"].append("pymdownx.inlinehilite")
        config["markdown_extensions"].append("pymdownx.magiclink")
        config["markdown_extensions"].append("pymdownx.mark")
        config["markdown_extensions"].append("pymdownx.smartsymbols")
        config["markdown_extensions"].append("pymdownx.superfences")
        config["markdown_extensions"].append("pymdownx.tasklist")
        config["mdx_configs"]["pymdownx.tasklist"] = {
            "custom_checkbox": True,
        }
        config["markdown_extensions"].append("pymdownx.tilde")

        config["markdown_extensions"].append("markdown_inline_graphviz")
        config["markdown_extensions"].append("plantuml_markdown")

        return config
Exemplo n.º 8
0
    def on_config(self, config):
        with open(
            os.path.join(self.tmp_dir_techdocs_theme.name, "techdocs_metadata.json"),
            "w+",
        ) as fp:
            fp.write(
                '{\n  "site_name": "{{ config.site_name }}",\n  "site_description": "{{ config.site_description }}"\n}'
            )

        mdx_configs_override = {}
        if "mdx_configs" in config:
            mdx_configs_override = config["mdx_configs"].copy()

        # Theme
        config["theme"] = Theme(
            name="material",
            static_templates=[
                "techdocs_metadata.json",
            ],
        )
        config["theme"].dirs.append(self.tmp_dir_techdocs_theme.name)

        # Plugins
        del config["plugins"]["techdocs-core"]

        search_plugin = SearchPlugin()
        search_plugin.load_config({})

        monorepo_plugin = MonorepoPlugin()
        monorepo_plugin.load_config({})
        config["plugins"]["search"] = search_plugin
        config["plugins"]["monorepo"] = monorepo_plugin

        # Markdown Extensions
        if "markdown_extensions" not in config:
            config["markdown_extensions"] = []

        if "mdx_configs" not in config:
            config["mdx_configs"] = {}

        config["markdown_extensions"].append("admonition")
        config["markdown_extensions"].append("toc")
        config["mdx_configs"]["toc"] = {
            "permalink": True,
        }

        config["markdown_extensions"].append("pymdownx.caret")
        config["markdown_extensions"].append("pymdownx.critic")
        config["markdown_extensions"].append("pymdownx.details")
        config["markdown_extensions"].append("pymdownx.emoji")
        config["mdx_configs"]["pymdownx.emoji"] = {"emoji_generator": to_svg}
        config["markdown_extensions"].append("pymdownx.inlinehilite")
        config["markdown_extensions"].append("pymdownx.magiclink")
        config["markdown_extensions"].append("pymdownx.mark")
        config["markdown_extensions"].append("pymdownx.smartsymbols")
        config["markdown_extensions"].append("pymdownx.superfences")
        config["mdx_configs"]["pymdownx.superfences"] = {
            "legacy_tab_classes": True,
        }
        config["markdown_extensions"].append("pymdownx.highlight")
        config["mdx_configs"]["pymdownx.highlight"] = {
            "linenums": True,
        }
        config["markdown_extensions"].append("pymdownx.extra")
        config["mdx_configs"]["pymdownx.betterem"] = {
            "smart_enable": "all",
        }
        config["markdown_extensions"].append("pymdownx.tabbed")
        config["markdown_extensions"].append("pymdownx.tasklist")
        config["mdx_configs"]["pymdownx.tasklist"] = {
            "custom_checkbox": True,
        }
        config["markdown_extensions"].append("pymdownx.tilde")

        config["markdown_extensions"].append("markdown_inline_graphviz")
        config["markdown_extensions"].append("plantuml_markdown")

        # merge config supplied by user in the mkdocs.yml
        for key in mdx_configs_override:
            if key in config["mdx_configs"]:
                default_config = config["mdx_configs"][key]
                override_config = mdx_configs_override[key]
                default_config.update(override_config)

        return config