From 1a316907433e1c4365bb90b00d7a08386ccbe514 Mon Sep 17 00:00:00 2001 From: dequis <dx@dxzone.com.ar> Date: Sun, 23 Jul 2023 23:00:50 +0200 Subject: [PATCH] docs: add support for mypystubs as a source for autodocs --- docs/conf.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/conf.py b/docs/conf.py index 1c11518f55..aa259b66f3 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -1,4 +1,6 @@ import os +import sys +import shutil # Configuration file for the Sphinx documentation builder. # @@ -17,6 +19,7 @@ author = 'ccc' extensions = [ 'sphinx_rtd_theme', + 'sphinx.ext.autodoc', ] templates_path = ['_templates'] @@ -38,3 +41,14 @@ html_theme_options = { 'logo_only': True, 'style_nav_header_background': "#000", } + +def setup(app): + tmpdir = "_build/mypystubs" + shutil.rmtree(tmpdir, ignore_errors=True) + shutil.copytree("../python_payload/mypystubs", tmpdir) + for filename in os.listdir(tmpdir): + full_path = os.path.join(tmpdir, filename) + os.rename(full_path, full_path.replace(".pyi", ".py")) + + sys.path.insert(0, os.path.abspath(tmpdir)) + sys.path.insert(1, os.path.abspath("../python_payload")) -- GitLab