[DOCS] Add warning for auto-generated docs

This commit is contained in:
Jesse Bannon 2025-08-17 06:52:56 -07:00
parent 7d9b4d9fa5
commit 413498639d
9 changed files with 44 additions and 2 deletions

View file

@ -1,3 +1,9 @@
..
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.
Plugins Plugins
======= =======

View file

@ -1,3 +1,9 @@
..
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.
Entry Variables Entry Variables
=============== ===============

View file

@ -1,3 +1,9 @@
..
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.
Scripting Functions Scripting Functions
=================== ===================

View file

@ -1,3 +1,9 @@
..
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.
Static Variables Static Variables
================ ================

View file

@ -1,6 +1,7 @@
import os import os
from abc import abstractmethod from abc import abstractmethod
from pathlib import Path from pathlib import Path
from typing import final
REGENERATE_DOCS: bool = bool(os.environ.get("REGENERATE_DOCS", 0)) REGENERATE_DOCS: bool = bool(os.environ.get("REGENERATE_DOCS", 0))
@ -12,6 +13,20 @@ 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.\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)

View file

@ -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:

View file

@ -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):

View file

@ -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:

View file

@ -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: