plugin docs
This commit is contained in:
parent
ba0a369692
commit
4681ca25b5
7 changed files with 87 additions and 30 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
Plugins
|
Plugins
|
||||||
=======
|
=======
|
||||||
|
|
||||||
|
|
@ -175,6 +176,45 @@ form of:
|
||||||
The output file will use the extension specified in ``convert_to``. Post-processing args
|
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``.
|
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
|
format
|
||||||
------
|
------
|
||||||
Set ``--format`` to pass into yt-dlp to download a specific format quality.
|
Set ``--format`` to pass into yt-dlp to download a specific format quality.
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
Override Variables
|
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/...``
|
``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
|
and ``https://url2.com/...``. Note that ``subscription_value_1`` also gets set to
|
||||||
``subscription_value``.
|
``subscription_value``.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
from tools.docgen.docgen import DocGen
|
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 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_file_md5_hash
|
||||||
from ytdl_sub.utils.file_handler import get_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:
|
class TestDocGen:
|
||||||
def test_entry_variables_generated(self):
|
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):
|
def test_scripting_functions_generated(self):
|
||||||
_test_doc_gen(ScriptingFunctionsDocGen)
|
_test_doc_gen(ScriptingFunctionsDocGen)
|
||||||
|
|
||||||
|
def test_plugins_generated(self):
|
||||||
|
_test_doc_gen(PluginsDocGen)
|
||||||
|
|
|
||||||
|
|
@ -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")
|
LOCATION = Path("docs/source/config_reference/scripting/entry_variables.rst")
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -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 get_function_docs
|
||||||
from tools.docgen.utils import section
|
from tools.docgen.utils import section
|
||||||
from tools.docgen.utils import static_methods
|
from tools.docgen.utils import static_methods
|
||||||
from ytdl_sub.entries.variables.override_variables import OverrideVariables
|
from ytdl_sub.entries.variables.override_variables import OverrideVariables
|
||||||
|
|
||||||
|
|
||||||
def generate_override_docs() -> str:
|
class OverrideVariablesDocGen(DocGen):
|
||||||
docs = section("Override Variables", level=0)
|
|
||||||
|
|
||||||
for name in static_methods(OverrideVariables):
|
LOCATION = Path("docs/source/config_reference/scripting/override_variables.rst")
|
||||||
docs += get_function_docs(
|
|
||||||
function_name=name,
|
|
||||||
obj=OverrideVariables,
|
|
||||||
level=1,
|
|
||||||
)
|
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
import inspect
|
import inspect
|
||||||
|
from pathlib import Path
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import Type
|
from typing import Type
|
||||||
|
|
||||||
|
from tools.docgen.docgen import DocGen
|
||||||
from tools.docgen.utils import get_function_docs
|
from tools.docgen.utils import get_function_docs
|
||||||
from tools.docgen.utils import properties
|
from tools.docgen.utils import properties
|
||||||
from tools.docgen.utils import section
|
from tools.docgen.utils import section
|
||||||
|
|
@ -20,6 +22,7 @@ def should_filter_property(property_name: str) -> bool:
|
||||||
"keys",
|
"keys",
|
||||||
"dict_with_format_strings",
|
"dict_with_format_strings",
|
||||||
"subscription_name",
|
"subscription_name",
|
||||||
|
"list",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -37,22 +40,24 @@ def generate_plugin_docs(name: str, options: Type[OptionsValidator], offset: int
|
||||||
return docs
|
return docs
|
||||||
|
|
||||||
|
|
||||||
def generate_plugin_rst():
|
class PluginsDocGen(DocGen):
|
||||||
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)
|
LOCATION = Path("docs/source/config_reference/plugins.rst")
|
||||||
for name in sorted(options_dict.keys()):
|
|
||||||
docs += generate_plugin_docs(name, options_dict[name], offset=1)
|
|
||||||
|
|
||||||
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
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
import inspect
|
import inspect
|
||||||
from pathlib import Path
|
|
||||||
from typing import Any
|
from typing import Any
|
||||||
from typing import Dict
|
from typing import Dict
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue