def drgndoc_init(app: sphinx.application.Sphinx) -> None: env = cast(DrgnDocBuildEnvironment, app.env) paths = [ os.path.join(app.confdir, path) for path in app.config.drgndoc_paths # type: ignore ] env.drgndoc_namespace = Namespace(parse_paths(paths, logger.warning)) env.drgndoc_formatter = Formatter( env.drgndoc_namespace, [ (re.compile(pattern), repl) for pattern, repl in app.config.drgndoc_substitutions # type: ignore ], )
"-m", "--module", dest="modules", metavar="MODULE[:NAME]", action="append", help="generate docstrings for the given module instead of all modules " "(may be given multiple times); " "an alternate name to use for the generated variables may also be given", ) parser.add_argument("paths", metavar="PATH", nargs="+", help="module or package path") args = parser.parse_args() modules = parse_paths(args.paths, functools.partial(print, file=sys.stderr)) namespace = Namespace(modules) formatter = Formatter(namespace) output_file = sys.stdout if args.header: output_file.write(f"""\ /* * Generated by drgndoc.docstrings -H. * * Before Python 3.7, various docstring fields were defined as char * (see * https://bugs.python.org/issue28761). We still want the strings to be * read-only, so just cast away the const. */ """)