Skip to content

Commit

Permalink
chore: use settings from root level
Browse files Browse the repository at this point in the history
  • Loading branch information
phil65 committed Nov 10, 2024
1 parent 1e318dc commit ecb0cfd
Show file tree
Hide file tree
Showing 8 changed files with 141 additions and 336 deletions.
100 changes: 23 additions & 77 deletions configs/mkdocs_mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,69 +8,12 @@ repo_path: https://github.com/mkdocs/mkdocs.git
clone_depth: 100
build_fn: mkdocs_mknodes:parse
build_kwargs:
pages:
- title: Home
type: MkText
text: "{{ metadata.description }}"
is_index: true
- Usage:
- type: MkTemplate
title: Getting started
template: https://raw.githubusercontent.com/mkdocs/mkdocs/master/docs/getting-started.md
- type: MkTemplate
title: Configuration
template: https://raw.githubusercontent.com/mkdocs/mkdocs/master/docs/user-guide/configuration.md
- type: MkTemplate
title: Deploying your docs
template: https://raw.githubusercontent.com/mkdocs/mkdocs/master/docs/user-guide/deploying-your-docs.md
- type: MkTemplate
title: Installation
template: https://raw.githubusercontent.com/mkdocs/mkdocs/master/docs/user-guide/installation.md
- title: API
type: MkDoc
section_name: "API"
recursive: true
- title: CLI
type: MkCliDoc
show_subcommands: true
condition: "{{ metadata.cli }}"
- Development:
- title: Changelog
type: MkChangelog
- title: Code of Conduct
type: MkCodeOfConduct
- title: Contributing
type: MkCommitConventions
- title: Pull requests
type: MkPullRequestGuidelines
- title: Dependencies
type: MkPage
items:
- title: Dependency table
type: MkDependencyTable
- title: Dependency tree
type: MkPipDepTree
direction: LR
- title: Dependencies
type: MkDependencyTable
- title: MkDocs Plugins
condition: '{{ "mkdocs.plugins" in metadata.entry_points }}'
type: MkPluginFlow
- title: License
type: MkLicense

plugins:
- mknodes:
repo_path: https://github.com/mkdocs/mkdocs.git
clone_depth: 100
build_fn: mkdocs_mknodes:parse
build_kwargs:
pages:
- title: Home
type: MkText
text: "{{ metadata.description }}"
is_index: true
- Usage:
pages:
- title: Home
type: MkText
text: "{{ metadata.description }}"
is_index: true
- Usage:
- type: MkTemplate
title: Getting started
template: https://raw.githubusercontent.com/mkdocs/mkdocs/master/docs/getting-started.md
Expand All @@ -83,15 +26,15 @@ plugins:
- type: MkTemplate
title: Installation
template: https://raw.githubusercontent.com/mkdocs/mkdocs/master/docs/user-guide/installation.md
- title: API
type: MkDoc
section_name: "API"
recursive: true
- title: CLI
type: MkCliDoc
show_subcommands: true
condition: "{{ metadata.cli }}"
- Development:
- title: API
type: MkDoc
section_name: "API"
recursive: true
- title: CLI
type: MkCliDoc
show_subcommands: true
condition: "{{ metadata.cli }}"
- Development:
- title: Changelog
type: MkChangelog
- title: Code of Conduct
Expand All @@ -103,15 +46,18 @@ plugins:
- title: Dependencies
type: MkPage
items:
- title: Dependency table
type: MkDependencyTable
- title: Dependency tree
type: MkPipDepTree
direction: LR
- title: Dependency table
type: MkDependencyTable
- title: Dependency tree
type: MkPipDepTree
direction: LR
- title: Dependencies
type: MkDependencyTable
- title: MkDocs Plugins
condition: '{{ "mkdocs.plugins" in metadata.entry_points }}'
type: MkPluginFlow
- title: License
type: MkLicense

plugins:
- mknodes
159 changes: 78 additions & 81 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,92 +8,89 @@ build_fn: mkdocs_mknodes.manual.root:Build.build
show_page_info: true
global_resources: false
theme:
name: material
custom_dir: overrides
icon:
logo: material/graph-outline
palette:
# Palette toggle for automatic mode
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode
name: material
custom_dir: overrides
icon:
logo: material/graph-outline
palette:
# Palette toggle for automatic mode
- media: "(prefers-color-scheme)"
toggle:
icon: material/brightness-auto
name: Switch to light mode

# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: custom
toggle:
icon: material/brightness-7
name: Switch to dark mode
# Palette toggle for light mode
- media: "(prefers-color-scheme: light)"
scheme: default
primary: custom
toggle:
icon: material/brightness-7
name: Switch to dark mode

# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: custom
toggle:
icon: material/brightness-4
name: Switch to system preference
features:
- announce.dismiss
- content.action.edit
- content.code.copy
- content.code.select
- content.code.annotate
- content.tooltips
# - content.tabs.link
- navigation.tracking # update URL based on current item in TOC
- navigation.path # shows breadcrumbs
- navigation.tabs # make top level tabs
- navigation.indexes # documents can be directly attached to sections (overview pages)
- navigation.footer # next/previous page buttons in footer
- navigation.top # adds back-to-top button
# - navigation.sections # top-level sections are rendered as groups
# - navigation.expand # expand all subsections in left sidebar by default
- toc.follow # makes toc follow scrolling
# - toc.integrate # integrates toc into left menu
- search.highlight
- search.suggest
# - search.share
# Palette toggle for dark mode
- media: "(prefers-color-scheme: dark)"
scheme: slate
primary: custom
toggle:
icon: material/brightness-4
name: Switch to system preference
features:
- announce.dismiss
- content.action.edit
- content.code.copy
- content.code.select
- content.code.annotate
- content.tooltips
# - content.tabs.link
- navigation.tracking # update URL based on current item in TOC
- navigation.path # shows breadcrumbs
- navigation.tabs # make top level tabs
- navigation.indexes # documents can be directly attached to sections (overview pages)
- navigation.footer # next/previous page buttons in footer
- navigation.top # adds back-to-top button
# - navigation.sections # top-level sections are rendered as groups
# - navigation.expand # expand all subsections in left sidebar by default
- toc.follow # makes toc follow scrolling
# - toc.integrate # integrates toc into left menu
- search.highlight
- search.suggest
# - search.share

plugins:
- search
- mknodes:
build_fn: mkdocs_mknodes.manual.root:Build.build
show_page_info: true
global_resources: false
- mkdocstrings:
default_handler: python
handlers:
python:
import:
- url: https://docs.python.org/3/objects.inv
domains: [std, py]
- url: https://phil65.github.io/mknodes/objects.inv
domains: [std, py]
options:
extensions:
- griffe_fieldz: { include_inherited: true }
# - griffe_pydantic:
# schema: true
# https://mkdocstrings.github.io/python/usage/
show_signature_annotations: true
show_symbol_type_toc: true
show_symbol_type_heading: true
show_root_toc_entry: false
# merge_init_into_class: true
ignore_init_summary: true
inherited_members: false
signature_crossrefs: true
separate_signature: true
line_length: 90
preload_modules:
- mknodes
- search
- mknodes
- mkdocstrings:
default_handler: python
handlers:
python:
import:
- url: https://docs.python.org/3/objects.inv
domains: [std, py]
- url: https://phil65.github.io/mknodes/objects.inv
domains: [std, py]
options:
extensions:
- griffe_fieldz: { include_inherited: true }
# - griffe_pydantic:
# schema: true
# https://mkdocstrings.github.io/python/usage/
show_signature_annotations: true
show_symbol_type_toc: true
show_symbol_type_heading: true
show_root_toc_entry: false
# merge_init_into_class: true
ignore_init_summary: true
inherited_members: false
signature_crossrefs: true
separate_signature: true
line_length: 90
preload_modules:
- mknodes
markdown_extensions:
- attr_list
- pymdownx.emoji
- toc:
permalink: true
- attr_list
- pymdownx.emoji
- toc:
permalink: true
# extra:
# social:
# - icon: fontawesome/brands/github
Expand Down
24 changes: 11 additions & 13 deletions mkdocs_mknodes/builders/configbuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
import os
from typing import Any

from mknodes.info import mkdocsconfigfile
import yamling

from mkdocs_mknodes import telemetry
from mkdocs_mknodes.appconfig import appconfig
from mkdocs_mknodes.plugin import mknodesconfig


Expand All @@ -17,7 +17,7 @@
class ConfigBuilder:
def __init__(
self,
configs: list[mkdocsconfigfile.MkDocsConfigFile] | None = None,
configs: list[appconfig.AppConfig] | None = None,
repo_path: str | None = ".",
build_fn: str | None = None,
clone_depth: int | None = 100,
Expand All @@ -28,27 +28,25 @@ def __init__(
self.clone_depth = clone_depth

def add_config_file(self, path: str | os.PathLike[str]):
cfg = mkdocsconfigfile.MkDocsConfigFile(path)
cfg = appconfig.AppConfig.from_yaml_file(path)
self.configs.append(cfg)

def build_mkdocs_config(
self, site_dir: str | os.PathLike[str] | None = None, **kwargs: Any
) -> mknodesconfig.MkNodesConfig:
cfg = self.configs[0]
if site_dir:
cfg["site_dir"] = site_dir
for plugin in cfg["plugins"]:
if "mknodes" in plugin:
if self.repo_path is not None:
plugin["mknodes"]["repo_path"] = self.repo_path
if self.build_fn is not None:
plugin["mknodes"]["build_fn"] = self.build_fn
if self.clone_depth is not None:
plugin["mknodes"]["clone_depth"] = self.clone_depth
cfg.site_dir = site_dir
if self.repo_path is not None:
cfg.repo_path = self.repo_path
if self.build_fn is not None:
cfg.build_fn = self.build_fn
if self.clone_depth is not None:
cfg.clone_depth = self.clone_depth
# cfg = {**cfg, **kwargs}
text = yamling.dump_yaml(dict(cfg))
buffer = io.StringIO(text)
buffer.name = cfg.path
buffer.name = cfg.config_file_path
config = mknodesconfig.MkNodesConfig.from_yaml(buffer, **kwargs)

for k, v in config.items():
Expand Down
11 changes: 6 additions & 5 deletions mkdocs_mknodes/commands/serve.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ def serve(
kwargs: Optional config values (overrides value from config)
"""
config = mkdocsconfigfile.MkDocsConfigFile(config_path)
config.update_mknodes_section(
repo_url=repo_path,
build_fn=build_fn,
clone_depth=clone_depth,
)
if repo_path is not None:
config._data["repo_path"] = repo_path
if build_fn is not None:
config._data["build_fn"] = build_fn
if clone_depth is not None:
config._data["clone_depth"] = clone_depth
if theme and theme != "material":
config.remove_plugin("social")
config.remove_plugin("tags")
Expand Down
Loading

0 comments on commit ecb0cfd

Please sign in to comment.