Skip to content

Is there a way to automatically exclude files without docstring? #547

Closed Answered by pawamoy
LuigiCerone asked this question in Q&A
Discussion options

You must be logged in to vote

Hello! Yes, there's a way if you use the automatic reference recipe, though note that it will make collection happen twice: once to filter out modules without any docstrings, and a second time when actually rendering modules to HTML.

In your script that generates the reference pages, collect data for your package and check if each module has any docstrings in it. Something like this (not tested):

from pathlib import Path

import griffe
import mkdocs_gen_files

nav = mkdocs_gen_files.Nav()
data = griffe.load("your_package")
for path in sorted(Path("src").rglob("*.py")):
    module_path = path.relative_to("src").with_suffix("")
    doc_path = path.relative_to("src").with_suffix(".md")
    f…

Replies: 5 comments 16 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by pawamoy
Comment options

You must be logged in to vote
1 reply
@pawamoy
Comment options

Comment options

You must be logged in to vote
1 reply
@pawamoy
Comment options

Comment options

You must be logged in to vote
5 replies
@pawamoy
Comment options

@quantfreedom
Comment options

@pawamoy
Comment options

@quantfreedom
Comment options

@pawamoy
Comment options

Comment options

You must be logged in to vote
9 replies
@pawamoy
Comment options

@quantfreedom
Comment options

@pawamoy
Comment options

@quantfreedom
Comment options

@pawamoy
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants
Converted from issue

This discussion was converted from issue #546 on April 05, 2023 14:26.