plugin docs

This commit is contained in:
Jesse Bannon 2023-12-28 10:27:16 -08:00
parent ba0a369692
commit 4681ca25b5
7 changed files with 87 additions and 30 deletions

View file

@ -1,3 +1,4 @@
Plugins
=======
@ -175,6 +176,45 @@ form of:
The output file will use the extension specified in ``convert_to``. Post-processing args
can still be set with ``convert_with`` set to ``yt-dlp``.
filter_exclude
--------------
Applies a conditional OR on any number of filters comprised of either variables or scripts.
If any filter evaluates to True, the entry will be excluded.
Usage:
.. code-block:: yaml
presets:
my_example_preset:
filter_exclude:
- { %contains( %lower(title), '#short' ) }
- { %contains( %lower(description), '#short' ) }
filter_include
--------------
Applies a conditional AND on any number of filters comprised of either variables or scripts.
If all filters evaluate to True, the entry will be included.
Usage:
.. code-block:: yaml
presets:
my_example_preset:
filter_include:
- {description}
- >-
{
%regex_search_any(
title,
[
"Full Episode",
"FULL",
]
)
}
format
------
Set ``--format`` to pass into yt-dlp to download a specific format quality.

View file

@ -1,3 +1,4 @@
Override Variables
==================
@ -41,4 +42,3 @@ For subscriptions in the form of
``subscription_value_1`` and ``subscription_value_2`` get set to ``https://url1.com/...``
and ``https://url2.com/...``. Note that ``subscription_value_1`` also gets set to
``subscription_value``.

View file

@ -1,7 +1,9 @@
from typing import Type
from tools.docgen.docgen import DocGen
from tools.docgen.entry_variables import EntryVariableDocGen
from tools.docgen.entry_variables import EntryVariablesDocGen
from tools.docgen.override_variables import OverrideVariablesDocGen
from tools.docgen.plugins import PluginsDocGen
from tools.docgen.scripting_functions import ScriptingFunctionsDocGen
from ytdl_sub.utils.file_handler import get_file_md5_hash
from ytdl_sub.utils.file_handler import get_md5_hash
@ -16,7 +18,13 @@ def _test_doc_gen(doc_gen: Type[DocGen]) -> None:
class TestDocGen:
def test_entry_variables_generated(self):
_test_doc_gen(EntryVariableDocGen)
_test_doc_gen(EntryVariablesDocGen)
def test_override_variables_generated(self):
_test_doc_gen(OverrideVariablesDocGen)
def test_scripting_functions_generated(self):
_test_doc_gen(ScriptingFunctionsDocGen)
def test_plugins_generated(self):
_test_doc_gen(PluginsDocGen)

View file

@ -20,7 +20,7 @@ def _variable_class_to_name(obj: Type[Any]) -> str:
)
class EntryVariableDocGen(DocGen):
class EntryVariablesDocGen(DocGen):
LOCATION = Path("docs/source/config_reference/scripting/entry_variables.rst")

View file

@ -1,20 +1,25 @@
from pathlib import Path
from tools.docgen.docgen import DocGen
from tools.docgen.utils import get_function_docs
from tools.docgen.utils import section
from tools.docgen.utils import static_methods
from ytdl_sub.entries.variables.override_variables import OverrideVariables
def generate_override_docs() -> str:
docs = section("Override Variables", level=0)
class OverrideVariablesDocGen(DocGen):
for name in static_methods(OverrideVariables):
docs += get_function_docs(
function_name=name,
obj=OverrideVariables,
level=1,
)
LOCATION = Path("docs/source/config_reference/scripting/override_variables.rst")
return docs
@classmethod
def generate(cls) -> str:
docs = section("Override Variables", level=0)
for name in static_methods(OverrideVariables):
docs += get_function_docs(
function_name=name,
obj=OverrideVariables,
level=1,
)
print(generate_override_docs())
return docs

View file

@ -1,7 +1,9 @@
import inspect
from pathlib import Path
from typing import Dict
from typing import Type
from tools.docgen.docgen import DocGen
from tools.docgen.utils import get_function_docs
from tools.docgen.utils import properties
from tools.docgen.utils import section
@ -20,6 +22,7 @@ def should_filter_property(property_name: str) -> bool:
"keys",
"dict_with_format_strings",
"subscription_name",
"list",
)
@ -37,22 +40,24 @@ def generate_plugin_docs(name: str, options: Type[OptionsValidator], offset: int
return docs
def generate_plugin_rst():
options_dict: Dict[str, Type[OptionsValidator]] = {
"output_options": OutputOptions,
"ytdl_options": YTDLOptions,
"overrides": Overrides,
}
for plugin_name, plugin_type in PluginMapping._MAPPING.items():
if plugin_name.startswith("_"):
continue
options_dict[plugin_name] = plugin_type.plugin_options_type
class PluginsDocGen(DocGen):
docs = section("Plugins", level=0)
for name in sorted(options_dict.keys()):
docs += generate_plugin_docs(name, options_dict[name], offset=1)
LOCATION = Path("docs/source/config_reference/plugins.rst")
return docs
@classmethod
def generate(cls):
options_dict: Dict[str, Type[OptionsValidator]] = {
"output_options": OutputOptions,
"ytdl_options": YTDLOptions,
"overrides": Overrides,
}
for plugin_name, plugin_type in PluginMapping._MAPPING.items():
if plugin_name.startswith("_"):
continue
options_dict[plugin_name] = plugin_type.plugin_options_type
docs = section("Plugins", level=0)
for name in sorted(options_dict.keys()):
docs += generate_plugin_docs(name, options_dict[name], offset=1)
print(generate_plugin_rst())
return docs

View file

@ -1,5 +1,4 @@
import inspect
from pathlib import Path
from typing import Any
from typing import Dict
from typing import List