[DOCS] Add warning for auto-generated docs (#1285)
This commit is contained in:
parent
7d9b4d9fa5
commit
191fa3c1bb
9 changed files with 48 additions and 2 deletions
|
|
@ -1,3 +1,10 @@
|
||||||
|
..
|
||||||
|
WARNING: This RST file is generated from docstrings in:
|
||||||
|
The respective plugin files under src/ytdl_sub/plugins/
|
||||||
|
In order to make a change to this file, edit the respective docstring
|
||||||
|
and run `make docs`. This will automatically sync the Python RST-based
|
||||||
|
docstrings into this file. If the docstrings and RST file are out of sync,
|
||||||
|
it will fail TestDocGen tests in GitHub CI.
|
||||||
|
|
||||||
Plugins
|
Plugins
|
||||||
=======
|
=======
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
..
|
||||||
|
WARNING: This RST file is generated from docstrings in:
|
||||||
|
src/ytdl_sub/entries/script/variable_definitions.py
|
||||||
|
In order to make a change to this file, edit the respective docstring
|
||||||
|
and run `make docs`. This will automatically sync the Python RST-based
|
||||||
|
docstrings into this file. If the docstrings and RST file are out of sync,
|
||||||
|
it will fail TestDocGen tests in GitHub CI.
|
||||||
|
|
||||||
Entry Variables
|
Entry Variables
|
||||||
===============
|
===============
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
..
|
||||||
|
WARNING: This RST file is generated from docstrings in:
|
||||||
|
The respective function files under src/ytdl_sub/script/functions/
|
||||||
|
In order to make a change to this file, edit the respective docstring
|
||||||
|
and run `make docs`. This will automatically sync the Python RST-based
|
||||||
|
docstrings into this file. If the docstrings and RST file are out of sync,
|
||||||
|
it will fail TestDocGen tests in GitHub CI.
|
||||||
|
|
||||||
Scripting Functions
|
Scripting Functions
|
||||||
===================
|
===================
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,10 @@
|
||||||
|
..
|
||||||
|
WARNING: This RST file is generated from docstrings in:
|
||||||
|
src/ytdl_sub/entries/variables/override_variables.py
|
||||||
|
In order to make a change to this file, edit the respective docstring
|
||||||
|
and run `make docs`. This will automatically sync the Python RST-based
|
||||||
|
docstrings into this file. If the docstrings and RST file are out of sync,
|
||||||
|
it will fail TestDocGen tests in GitHub CI.
|
||||||
|
|
||||||
Static Variables
|
Static Variables
|
||||||
================
|
================
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,21 @@ class DocGen:
|
||||||
|
|
||||||
LOCATION: Path
|
LOCATION: Path
|
||||||
|
|
||||||
|
# human-readable location of where to edit the underlying docstrings
|
||||||
|
DOCSTRING_LOCATION: str
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def _generate_warning(cls) -> str:
|
||||||
|
return (
|
||||||
|
"..\n"
|
||||||
|
" WARNING: This RST file is generated from docstrings in:\n"
|
||||||
|
f" {cls.DOCSTRING_LOCATION}\n"
|
||||||
|
" In order to make a change to this file, edit the respective docstring\n"
|
||||||
|
" and run `make docs`. This will automatically sync the Python RST-based\n"
|
||||||
|
" docstrings into this file. If the docstrings and RST file are out of sync,\n"
|
||||||
|
" it will fail TestDocGen tests in GitHub CI.\n"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def generate(cls) -> str:
|
def generate(cls) -> str:
|
||||||
|
|
@ -25,7 +40,7 @@ class DocGen:
|
||||||
Maybe writes the docs to their file if the global is set to True, and returns
|
Maybe writes the docs to their file if the global is set to True, and returns
|
||||||
the generated docs
|
the generated docs
|
||||||
"""
|
"""
|
||||||
contents = cls.generate()
|
contents = cls._generate_warning() + cls.generate()
|
||||||
if REGENERATE_DOCS:
|
if REGENERATE_DOCS:
|
||||||
with open(cls.LOCATION, "w", encoding="utf-8") as out:
|
with open(cls.LOCATION, "w", encoding="utf-8") as out:
|
||||||
out.write(contents)
|
out.write(contents)
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ def _variable_class_to_name(obj: Type[Any]) -> str:
|
||||||
class EntryVariablesDocGen(DocGen):
|
class EntryVariablesDocGen(DocGen):
|
||||||
|
|
||||||
LOCATION = Path("docs/source/config_reference/scripting/entry_variables.rst")
|
LOCATION = Path("docs/source/config_reference/scripting/entry_variables.rst")
|
||||||
|
DOCSTRING_LOCATION = "src/ytdl_sub/entries/script/variable_definitions.py"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls) -> str:
|
def generate(cls) -> str:
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ import inspect
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import Optional
|
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
from tools.docgen.docgen import DocGen
|
from tools.docgen.docgen import DocGen
|
||||||
|
|
@ -72,6 +71,7 @@ def generate_plugin_docs(name: str, options: Type[OptionsValidator], offset: int
|
||||||
class PluginsDocGen(DocGen):
|
class PluginsDocGen(DocGen):
|
||||||
|
|
||||||
LOCATION = Path("docs/source/config_reference/plugins.rst")
|
LOCATION = Path("docs/source/config_reference/plugins.rst")
|
||||||
|
DOCSTRING_LOCATION = "The respective plugin files under src/ytdl_sub/plugins/"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls):
|
def generate(cls):
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ def get_function_docstring(
|
||||||
class ScriptingFunctionsDocGen(DocGen):
|
class ScriptingFunctionsDocGen(DocGen):
|
||||||
|
|
||||||
LOCATION = Path("docs/source/config_reference/scripting/scripting_functions.rst")
|
LOCATION = Path("docs/source/config_reference/scripting/scripting_functions.rst")
|
||||||
|
DOCSTRING_LOCATION = "The respective function files under src/ytdl_sub/script/functions/"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls) -> str:
|
def generate(cls) -> str:
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ from ytdl_sub.entries.variables.override_variables import SubscriptionVariables
|
||||||
class StaticVariablesDocGen(DocGen):
|
class StaticVariablesDocGen(DocGen):
|
||||||
|
|
||||||
LOCATION = Path("docs/source/config_reference/scripting/static_variables.rst")
|
LOCATION = Path("docs/source/config_reference/scripting/static_variables.rst")
|
||||||
|
DOCSTRING_LOCATION = "src/ytdl_sub/entries/variables/override_variables.py"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def generate(cls) -> str:
|
def generate(cls) -> str:
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue