Skip to content
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

Unable to get docstring summary, and supress the remainder of the docstring #139

Open
bschollnick opened this issue Mar 7, 2024 · 2 comments
Assignees
Labels
config Related to configuration options feature New feature or request

Comments

@bschollnick
Copy link

Description of the bug

From my reading of the documentation, I don't see any way to supress the docstring, and only show the summary line(s) of the docstring.
We are hoping to have 2 different blocks.... One will only show the summary (being a "non-technical") summary, and then another in a collapsed annotation that has the whole 9 yards.

This allows the documentation to be used for non-technical (non-programmers), using the summary only listing, And allow programmers to view the same documentation.

I see a "summary" option,

summary (bool | dict[str, bool]): Whether to render summaries of modules, classes, functions (methods) and attributes.

But it seems to do nothing...

e.g. summary: true, appears to do nothing.

To Reproduce

 Example:
::: application.checkers.hoster.hostingclass
    options:
      show_source: false
      heading_level: 2
      parameter_headings: false
      merge_init_into_class: true
      docstring_options:
        ignore_init_summary: false
        trim_doctest_flags: false
      summary: true
      show_docstring_parameters: false
      show_docstring_raises: false
      show_docstring_receives: false
      show_docstring_yields: false
      show_docstring_warns: false
      show_docstring_description: false
      show_docstring_returns: false
      show_docstring_examples: false

As mentioned, using mkdocs w/mkdocstring[python] plugin, seems to work fine except I can't get the summary option to work.

Expected behavior

The ability to show the docstring summary, without the rest of the docstring.

Environment information

python -m mkdocstrings_handlers.python.debug  # | xclip -selection clipboard

> No module named mkdocstrings_handlers.python.debug

The following libraries are loaded:
mkdocs 1.5.3 Project documentation with Markdown.
mkdocs-autorefs 1.0.1 Automatically link across pages in MkDocs.
mkdocs-material 9.5.10 Documentation that simply works
mkdocs-material-extensions 1.3.1 Extension pack for Python Markdown and MkDocs Material.
mkdocstrings 0.24.1 Automatic documentation from sources, for MkDocs.
mkdocstrings-python 1.7.3 A Python handler for mkdocstrings.

@pawamoy
Copy link
Member

pawamoy commented Mar 7, 2024

Hello, thanks for the report.

The summary option is documented here: https://mkdocstrings.github.io/python/usage/configuration/members/#summary. It's used to automatically create lists/tables of attributes, functions, classes, and submodules, using the docstring summary of each object.

For example, see it in action here: https://mkdocstrings.github.io/python/reference/mkdocstrings_handlers/python/rendering/. The "classes" and "functions" lists are auto-generated. Each name is a link that will bring you to the full documentation of the relevant object.

If this option does nothing for you, it's probably because you are not using the Insiders version of mkdocstrings-python: this feature is available to sponsors only (as explained in the docs). It will become available to everyone once the $1000/month goal is reached, see https://mkdocstrings.github.io/python/insiders/#1000-gravifridge-user-manual 🙂

Would this option work for you, or would you prefer to get an additional option like show_docstring_summary, that you could set to true and combine with show_docstring_description: false in order to only show the summary of a given object?

@bschollnick
Copy link
Author

Yes, an excellent option would be show_docstring_summary: true/false boolean would easily solve that issue...

@pawamoy pawamoy added feature New feature or request config Related to configuration options labels Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
config Related to configuration options feature New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants