Skip to content

Commit

Permalink
fix: mkdocstrings unable to parse custom theme directory configuration
Browse files Browse the repository at this point in the history
This fixes the mkdocs-material's custom_dir configuration, where theme `name` is set to null in mkdocs.yaml.
Thereby, this fix adds support to automatically read theme_name from `dirs` attribute, if `name` attribute is None(null), otherwise default behaviour will occur.

Fixes mkdocstrings#120.
  • Loading branch information
abhiTronix committed Jun 5, 2020
1 parent e114b21 commit b2ccc22
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/mkdocstrings/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import logging
import random
import re
import os
import string
from typing import Any, Callable, Dict, List, Match, Optional, Pattern, Tuple

Expand Down Expand Up @@ -151,8 +152,14 @@ def on_config(self, config: Config, **kwargs) -> Config:

log.debug("mkdocstrings.plugin: Adding extension to the list")

theme_name = None
if config["theme"].name is None:
theme_name = os.path.dirname(config["theme"].dirs[0])
else:
theme_name = config["theme"].name

extension_config = {
"theme_name": config["theme"].name,
"theme_name": theme_name,
"mdx": config["markdown_extensions"],
"mdx_configs": config["mdx_configs"],
"mkdocstrings": self.config,
Expand Down

0 comments on commit b2ccc22

Please sign in to comment.