Skip to content

Fine grain config #289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions scripts/griffe_extensions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
class CustomFields(griffe.Extension):
"""Support our custom dataclass fields."""

_custom_field_path = "mkdocstrings_handlers.python._internal.config._Field"

def on_attribute_instance(
self,
*,
Expand All @@ -24,11 +26,11 @@ def on_attribute_instance(
if attr.docstring:
return
try:
field: griffe.ExprCall = attr.annotation.slice.elements[1] # type: ignore[union-attr]
field = attr.annotation.slice.elements[1] # type: ignore[union-attr]
except AttributeError:
return

if field.canonical_path == "mkdocstrings_handlers.python._internal.config._Field":
if isinstance(field, griffe.ExprCall) and field.canonical_path == self._custom_field_path:
description = next(
attr.value
for attr in field.arguments
Expand Down
14 changes: 10 additions & 4 deletions src/mkdocstrings_handlers/python/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
"""Python handler for mkdocstrings."""

from mkdocstrings_handlers.python._internal.config import (
UNSET,
AutoStyleOptions,
ChainedOptions,
GoogleStyleOptions,
Inventory,
MembersOption,
NumpyStyleOptions,
PerStyleOptions,
PythonConfig,
PythonInputConfig,
PythonInputOptions,
PythonOptions,
RecursiveOptions,
SphinxStyleOptions,
SummaryOption,
Unset,
)
from mkdocstrings_handlers.python._internal.handler import PythonHandler, get_handler
from mkdocstrings_handlers.python._internal.rendering import (
Expand All @@ -23,23 +28,24 @@
do_as_functions_section,
do_as_modules_section,
do_backlink_tree,
do_crossref,
do_filter_objects,
do_format_attribute,
do_format_code,
do_format_signature,
do_get_template,
do_multi_crossref,
do_order_members,
do_split_path,
do_stash_crossref,
)

__all__ = [
"UNSET",
"AutoStyleOptions",
"AutorefsHook",
"ChainedOptions",
"GoogleStyleOptions",
"Inventory",
"MembersOption",
"NumpyStyleOptions",
"Order",
"PerStyleOptions",
Expand All @@ -48,21 +54,21 @@
"PythonInputConfig",
"PythonInputOptions",
"PythonOptions",
"RecursiveOptions",
"SphinxStyleOptions",
"SummaryOption",
"Tree",
"Unset",
"do_as_attributes_section",
"do_as_classes_section",
"do_as_functions_section",
"do_as_modules_section",
"do_backlink_tree",
"do_crossref",
"do_filter_objects",
"do_format_attribute",
"do_format_code",
"do_format_signature",
"do_get_template",
"do_multi_crossref",
"do_order_members",
"do_split_path",
"do_stash_crossref",
Expand Down
Loading
Loading