diff --git a/docs/source/config_reference/plugins.rst b/docs/source/config_reference/plugins.rst index 451a0ed8..69e3de7e 100644 --- a/docs/source/config_reference/plugins.rst +++ b/docs/source/config_reference/plugins.rst @@ -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. diff --git a/docs/source/config_reference/scripting/override_variables.rst b/docs/source/config_reference/scripting/override_variables.rst index 7cb23e4a..3b02c4c7 100644 --- a/docs/source/config_reference/scripting/override_variables.rst +++ b/docs/source/config_reference/scripting/override_variables.rst @@ -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``. - diff --git a/tests/unit/docgen/test_docgen.py b/tests/unit/docgen/test_docgen.py index 8b2477c4..e70ad460 100644 --- a/tests/unit/docgen/test_docgen.py +++ b/tests/unit/docgen/test_docgen.py @@ -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) diff --git a/tools/docgen/entry_variables.py b/tools/docgen/entry_variables.py index 32bba9ed..9f3728d7 100644 --- a/tools/docgen/entry_variables.py +++ b/tools/docgen/entry_variables.py @@ -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") diff --git a/tools/docgen/override_variables.py b/tools/docgen/override_variables.py index f5b35dd5..e919877c 100644 --- a/tools/docgen/override_variables.py +++ b/tools/docgen/override_variables.py @@ -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 diff --git a/tools/docgen/plugins.py b/tools/docgen/plugins.py index 514b2a6b..b71218b3 100644 --- a/tools/docgen/plugins.py +++ b/tools/docgen/plugins.py @@ -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 diff --git a/tools/docgen/utils.py b/tools/docgen/utils.py index 0daa697a..d236bb5f 100644 --- a/tools/docgen/utils.py +++ b/tools/docgen/utils.py @@ -1,5 +1,4 @@ import inspect -from pathlib import Path from typing import Any from typing import Dict from typing import List