simplibs-extractor-html 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- simplibs/extractor_html/__init__.py +82 -0
- simplibs/extractor_html/actions/ApplyToHtmlBlocks.py +29 -0
- simplibs/extractor_html/actions/CleanupHtmlWhitespace.py +22 -0
- simplibs/extractor_html/actions/CompactHtml.py +22 -0
- simplibs/extractor_html/actions/HtmlOutline.py +23 -0
- simplibs/extractor_html/actions/RemoveTemplateImports.py +22 -0
- simplibs/extractor_html/actions/StripHtmlComments.py +23 -0
- simplibs/extractor_html/actions/StripTemplateComments.py +27 -0
- simplibs/extractor_html/actions/TemplateOutline.py +23 -0
- simplibs/extractor_html/actions/__init__.py +57 -0
- simplibs/extractor_html/annotations/TemplateEngine.py +26 -0
- simplibs/extractor_html/annotations/__init__.py +14 -0
- simplibs/extractor_html/constants/HTML_ANY_TAG_PATTERN.py +16 -0
- simplibs/extractor_html/constants/HTML_BLOCK_LANGUAGE_BY_TYPE.py +41 -0
- simplibs/extractor_html/constants/HTML_COMMENT_END_PATTERN.py +19 -0
- simplibs/extractor_html/constants/HTML_CONDITIONAL_PATTERN.py +23 -0
- simplibs/extractor_html/constants/HTML_DEPENDENCY_DIR_NAMES.py +18 -0
- simplibs/extractor_html/constants/HTML_EXTRA_LANGUAGE_BY_SUFFIX.py +31 -0
- simplibs/extractor_html/constants/HTML_HEADING_ELEMENTS.py +15 -0
- simplibs/extractor_html/constants/HTML_ID_ATTRIBUTE_PATTERN.py +21 -0
- simplibs/extractor_html/constants/HTML_IMPLIED_END.py +34 -0
- simplibs/extractor_html/constants/HTML_LICENSE_START.py +14 -0
- simplibs/extractor_html/constants/HTML_LICENSE_TAGS.py +14 -0
- simplibs/extractor_html/constants/HTML_OUTLINE_ELEMENTS.py +32 -0
- simplibs/extractor_html/constants/HTML_OUTLINE_TEXT_LIMIT.py +15 -0
- simplibs/extractor_html/constants/HTML_OUTPUT_DIR_NAMES.py +43 -0
- simplibs/extractor_html/constants/HTML_PLAIN_SUFFIXES.py +18 -0
- simplibs/extractor_html/constants/HTML_RAW_TEXT_END_PATTERNS.py +28 -0
- simplibs/extractor_html/constants/HTML_SUFFIXES.py +22 -0
- simplibs/extractor_html/constants/HTML_TAG_NAME_PATTERN.py +16 -0
- simplibs/extractor_html/constants/HTML_TEMPLATE_BLOCKS.py +38 -0
- simplibs/extractor_html/constants/HTML_TEMPLATE_IMPORT_TAGS.py +29 -0
- simplibs/extractor_html/constants/HTML_TEMPLATE_OUTLINE_TAGS.py +35 -0
- simplibs/extractor_html/constants/HTML_TEMPLATE_SUFFIXES.py +19 -0
- simplibs/extractor_html/constants/HTML_TEMPLATE_TAG_NAME_PATTERN.py +16 -0
- simplibs/extractor_html/constants/HTML_TEMPLATE_TOKEN_PATTERN.py +16 -0
- simplibs/extractor_html/constants/HTML_TEXT_ELEMENTS.py +16 -0
- simplibs/extractor_html/constants/HTML_TOKEN_PATTERN.py +26 -0
- simplibs/extractor_html/constants/HTML_TYPE_ATTRIBUTE_PATTERN.py +21 -0
- simplibs/extractor_html/constants/HTML_VOID_ELEMENTS.py +21 -0
- simplibs/extractor_html/constants/HTML_WRAPPED_STEM_ENDING.py +14 -0
- simplibs/extractor_html/constants/HTML_WRAPPED_SUFFIXES.py +15 -0
- simplibs/extractor_html/constants/__init__.py +77 -0
- simplibs/extractor_html/file_rules/__init__.py +56 -0
- simplibs/extractor_html/file_rules/atomic/DEPENDENCY_DIRS.py +17 -0
- simplibs/extractor_html/file_rules/atomic/DOT_NAME.py +19 -0
- simplibs/extractor_html/file_rules/atomic/OUTPUT_DIRS.py +17 -0
- simplibs/extractor_html/file_rules/atomic/VCS_DIRS.py +21 -0
- simplibs/extractor_html/file_rules/atomic/WRAPPED_HTML.py +22 -0
- simplibs/extractor_html/file_rules/atomic/__init__.py +26 -0
- simplibs/extractor_html/file_rules/html/HTML_BASE.py +22 -0
- simplibs/extractor_html/file_rules/html/HTML_FILES.py +24 -0
- simplibs/extractor_html/file_rules/html/HTML_PLAIN_BASE.py +24 -0
- simplibs/extractor_html/file_rules/html/HTML_STRICT_EXCLUDE.py +21 -0
- simplibs/extractor_html/file_rules/html/__init__.py +20 -0
- simplibs/extractor_html/logic/__init__.py +44 -0
- simplibs/extractor_html/logic/_helpers/HtmlBlock.py +31 -0
- simplibs/extractor_html/logic/_helpers/HtmlOutlineBuilder.py +189 -0
- simplibs/extractor_html/logic/_helpers/HtmlScan.py +50 -0
- simplibs/extractor_html/logic/_helpers/HtmlTag.py +32 -0
- simplibs/extractor_html/logic/_helpers/Ranges.py +48 -0
- simplibs/extractor_html/logic/_helpers/TemplateScan.py +43 -0
- simplibs/extractor_html/logic/_helpers/TemplateTag.py +33 -0
- simplibs/extractor_html/logic/_helpers/__init__.py +68 -0
- simplibs/extractor_html/logic/_helpers/blank_spans.py +40 -0
- simplibs/extractor_html/logic/_helpers/build_html_outline.py +38 -0
- simplibs/extractor_html/logic/_helpers/build_template_outline.py +75 -0
- simplibs/extractor_html/logic/_helpers/find_blanks_start.py +29 -0
- simplibs/extractor_html/logic/_helpers/find_block_language.py +35 -0
- simplibs/extractor_html/logic/_helpers/find_comments.py +60 -0
- simplibs/extractor_html/logic/_helpers/find_protected_spans.py +48 -0
- simplibs/extractor_html/logic/_helpers/find_template_import_spans.py +37 -0
- simplibs/extractor_html/logic/_helpers/fit_removal_span.py +40 -0
- simplibs/extractor_html/logic/_helpers/is_license_comment.py +26 -0
- simplibs/extractor_html/logic/_helpers/line_of.py +23 -0
- simplibs/extractor_html/logic/_helpers/raise_block_result_invalid.py +38 -0
- simplibs/extractor_html/logic/_helpers/replace_spans.py +42 -0
- simplibs/extractor_html/logic/_helpers/scan_checked.py +45 -0
- simplibs/extractor_html/logic/_helpers/scan_html.py +208 -0
- simplibs/extractor_html/logic/_helpers/scan_templates.py +128 -0
- simplibs/extractor_html/logic/_helpers/scan_templates_checked.py +39 -0
- simplibs/extractor_html/logic/_helpers/skip_html_comment.py +41 -0
- simplibs/extractor_html/logic/_helpers/skip_html_tag.py +46 -0
- simplibs/extractor_html/logic/_helpers/tidy_lines.py +86 -0
- simplibs/extractor_html/logic/_helpers/warn_problems.py +32 -0
- simplibs/extractor_html/logic/apply_to_html_blocks.py +103 -0
- simplibs/extractor_html/logic/cleanup_html_whitespace.py +54 -0
- simplibs/extractor_html/logic/compact_html.py +44 -0
- simplibs/extractor_html/logic/html_comment_spans.py +54 -0
- simplibs/extractor_html/logic/html_outline.py +66 -0
- simplibs/extractor_html/logic/strip_html_comments.py +63 -0
- simplibs/extractor_html/logic/templates/__init__.py +25 -0
- simplibs/extractor_html/logic/templates/remove_template_imports.py +51 -0
- simplibs/extractor_html/logic/templates/strip_template_comments.py +60 -0
- simplibs/extractor_html/logic/templates/template_comment_spans.py +49 -0
- simplibs/extractor_html/logic/templates/template_outline.py +62 -0
- simplibs/extractor_html/plugin/__init__.py +14 -0
- simplibs/extractor_html/plugin/register_all.py +60 -0
- simplibs/extractor_html/presets/__init__.py +43 -0
- simplibs/extractor_html/presets/html_clean_steps.py +54 -0
- simplibs/extractor_html/presets/html_no_imports_steps.py +50 -0
- simplibs/extractor_html/presets/html_outline_steps.py +28 -0
- simplibs/extractor_html/presets/template_structure_steps.py +27 -0
- simplibs/extractor_html/profiles/DJANGO_CLEAN.py +36 -0
- simplibs/extractor_html/profiles/DJANGO_NO_IMPORTS.py +32 -0
- simplibs/extractor_html/profiles/DJANGO_OUTLINE.py +32 -0
- simplibs/extractor_html/profiles/DJANGO_STRUCTURE.py +32 -0
- simplibs/extractor_html/profiles/HTML_CODE_CLEAN.py +32 -0
- simplibs/extractor_html/profiles/HTML_CODE_NO_IMPORTS.py +30 -0
- simplibs/extractor_html/profiles/HTML_DATA_ALL.py +26 -0
- simplibs/extractor_html/profiles/HTML_OUTLINE.py +31 -0
- simplibs/extractor_html/profiles/HTML_PROFILES.py +42 -0
- simplibs/extractor_html/profiles/HTML_SRC_CLEAN.py +31 -0
- simplibs/extractor_html/profiles/JINJA_CLEAN.py +35 -0
- simplibs/extractor_html/profiles/JINJA_NO_IMPORTS.py +32 -0
- simplibs/extractor_html/profiles/JINJA_OUTLINE.py +30 -0
- simplibs/extractor_html/profiles/JINJA_STRUCTURE.py +31 -0
- simplibs/extractor_html/profiles/__init__.py +86 -0
- simplibs/extractor_html/profiles/steps_for_engine.py +39 -0
- simplibs/extractor_html/profiles/steps_for_pages.py +36 -0
- simplibs/extractor_html/py.typed +1 -0
- simplibs_extractor_html-0.1.0.dist-info/METADATA +504 -0
- simplibs_extractor_html-0.1.0.dist-info/RECORD +127 -0
- simplibs_extractor_html-0.1.0.dist-info/WHEEL +5 -0
- simplibs_extractor_html-0.1.0.dist-info/entry_points.txt +2 -0
- simplibs_extractor_html-0.1.0.dist-info/licenses/LICENSE +21 -0
- simplibs_extractor_html-0.1.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
from .DJANGO_CLEAN import DJANGO_CLEAN
|
|
2
|
+
from .DJANGO_NO_IMPORTS import DJANGO_NO_IMPORTS
|
|
3
|
+
from .DJANGO_OUTLINE import DJANGO_OUTLINE
|
|
4
|
+
from .DJANGO_STRUCTURE import DJANGO_STRUCTURE
|
|
5
|
+
from .HTML_CODE_CLEAN import HTML_CODE_CLEAN
|
|
6
|
+
from .HTML_CODE_NO_IMPORTS import HTML_CODE_NO_IMPORTS
|
|
7
|
+
from .HTML_DATA_ALL import HTML_DATA_ALL
|
|
8
|
+
from .HTML_OUTLINE import HTML_OUTLINE
|
|
9
|
+
from .HTML_PROFILES import HTML_PROFILES
|
|
10
|
+
from .HTML_SRC_CLEAN import HTML_SRC_CLEAN
|
|
11
|
+
from .JINJA_CLEAN import JINJA_CLEAN
|
|
12
|
+
from .JINJA_NO_IMPORTS import JINJA_NO_IMPORTS
|
|
13
|
+
from .JINJA_OUTLINE import JINJA_OUTLINE
|
|
14
|
+
from .JINJA_STRUCTURE import JINJA_STRUCTURE
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
__all__ = [
|
|
18
|
+
"DJANGO_CLEAN",
|
|
19
|
+
"DJANGO_NO_IMPORTS",
|
|
20
|
+
"DJANGO_OUTLINE",
|
|
21
|
+
"DJANGO_STRUCTURE",
|
|
22
|
+
"HTML_CODE_CLEAN",
|
|
23
|
+
"HTML_CODE_NO_IMPORTS",
|
|
24
|
+
"HTML_DATA_ALL",
|
|
25
|
+
"HTML_OUTLINE",
|
|
26
|
+
"HTML_PROFILES",
|
|
27
|
+
"HTML_SRC_CLEAN",
|
|
28
|
+
"JINJA_CLEAN",
|
|
29
|
+
"JINJA_NO_IMPORTS",
|
|
30
|
+
"JINJA_OUTLINE",
|
|
31
|
+
"JINJA_STRUCTURE",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
_DESIGN_NOTES = """
|
|
36
|
+
# simplibs.extractor_html.profiles — The Profiles Themselves
|
|
37
|
+
|
|
38
|
+
## Purpose
|
|
39
|
+
The thirteen profiles as `Profile` objects of the extractor. Registering them
|
|
40
|
+
is the job of `register_all`; having them as objects lets a program use one
|
|
41
|
+
directly or build its own on top of it.
|
|
42
|
+
|
|
43
|
+
from simplibs.extractor_html.profiles import DJANGO_CLEAN
|
|
44
|
+
from dataclasses import replace
|
|
45
|
+
mine = replace(DJANGO_CLEAN, name="mine", output_name="mine.md")
|
|
46
|
+
|
|
47
|
+
## Domain Folder
|
|
48
|
+
`profiles/` has its own `__all__` and is not re-exported from the package root.
|
|
49
|
+
|
|
50
|
+
## Three Families
|
|
51
|
+
* **Pages** (`code-clean`, `code-no-imports`, `data-all`, `src-clean`, `outline`):
|
|
52
|
+
`.html` is read as a page without an engine, the suffixes of the Jinja family
|
|
53
|
+
as Jinja.
|
|
54
|
+
* **Django** (`django-clean`, `django-no-imports`, `django-outline`,
|
|
55
|
+
`django-structure`): every `.html` file is read as a Django template.
|
|
56
|
+
* **Jinja** (`jinja-clean`, `jinja-no-imports`, `jinja-outline`,
|
|
57
|
+
`jinja-structure`): every page and template suffix is read as Jinja.
|
|
58
|
+
|
|
59
|
+
The profiles named after an engine are strict: they leave out packages and
|
|
60
|
+
generated output.
|
|
61
|
+
|
|
62
|
+
## Internal Components Registry
|
|
63
|
+
|
|
64
|
+
| Component | Type | Description |
|
|
65
|
+
| :-------------------- | :------ | :---------------------------------------------------------------------- |
|
|
66
|
+
| `DJANGO_CLEAN` | Profile | `html/django-clean`. |
|
|
67
|
+
| `DJANGO_NO_IMPORTS` | Profile | `html/django-no-imports`. |
|
|
68
|
+
| `DJANGO_OUTLINE` | Profile | `html/django-outline`. |
|
|
69
|
+
| `DJANGO_STRUCTURE` | Profile | `html/django-structure`. |
|
|
70
|
+
| `HTML_CODE_CLEAN` | Profile | `html/code-clean`. |
|
|
71
|
+
| `HTML_CODE_NO_IMPORTS`| Profile | `html/code-no-imports`. |
|
|
72
|
+
| `HTML_DATA_ALL` | Profile | `html/data-all`. |
|
|
73
|
+
| `HTML_OUTLINE` | Profile | `html/outline`. |
|
|
74
|
+
| `HTML_PROFILES` | Tuple | All thirteen profiles, in the order the listings show them. |
|
|
75
|
+
| `HTML_SRC_CLEAN` | Profile | `html/src-clean`. |
|
|
76
|
+
| `JINJA_CLEAN` | Profile | `html/jinja-clean`. |
|
|
77
|
+
| `JINJA_NO_IMPORTS` | Profile | `html/jinja-no-imports`. |
|
|
78
|
+
| `JINJA_OUTLINE` | Profile | `html/jinja-outline`. |
|
|
79
|
+
| `JINJA_STRUCTURE` | Profile | `html/jinja-structure`. |
|
|
80
|
+
| `steps_for_engine` | Module | Private: the steps of a project written for one engine. |
|
|
81
|
+
| `steps_for_pages` | Module | Private: the engine chosen by the suffix. |
|
|
82
|
+
|
|
83
|
+
## Layering & Design
|
|
84
|
+
- `by_suffix` (one step for a family of file types) is a tool of `simplibs-extractor`.
|
|
85
|
+
- The steps for the code inside a page come from the add-ons of its languages.
|
|
86
|
+
"""
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from simplibs.actions import Action
|
|
3
|
+
from simplibs.extractor import by_suffix
|
|
4
|
+
# Outers
|
|
5
|
+
from ..annotations import TemplateEngine
|
|
6
|
+
from ..constants import HTML_PLAIN_SUFFIXES, HTML_SUFFIXES
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def steps_for_engine(make: Callable[[TemplateEngine], Action], engine: TemplateEngine) -> dict[str, Action]:
|
|
10
|
+
"""Give every suffix of a project written for one engine the steps of that engine.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
make: A function from the engine to the steps (`html_clean_steps`...).
|
|
14
|
+
engine: `"django"` or `"jinja"`.
|
|
15
|
+
|
|
16
|
+
Returns:
|
|
17
|
+
A mapping `suffix -> step`, the form of `Profile.steps` that chooses by file type.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
# 1. A Django project keeps its templates in `.html` files; a Jinja project may use every suffix
|
|
21
|
+
suffixes = HTML_PLAIN_SUFFIXES if engine == "django" else HTML_SUFFIXES
|
|
22
|
+
return by_suffix(make(engine), suffixes)
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
_DESIGN_NOTES = """
|
|
26
|
+
# steps_for_engine — A Project of One Engine
|
|
27
|
+
|
|
28
|
+
## Purpose
|
|
29
|
+
The profiles named after an engine (`django-clean`, `jinja-outline`...) say
|
|
30
|
+
which engine every file is written for, so each suffix gets the same engine.
|
|
31
|
+
|
|
32
|
+
## Which Suffixes
|
|
33
|
+
Django reads `.html`, `.htm` and `.xhtml`. Jinja (and Nunjucks) also have
|
|
34
|
+
suffixes of their own, and a Jinja project may keep its pages in `.html` or in
|
|
35
|
+
those, so all of them are taken.
|
|
36
|
+
|
|
37
|
+
## Not Exported
|
|
38
|
+
A tool of the profiles' own: it is not in `__all__` of the folder.
|
|
39
|
+
"""
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
from collections.abc import Callable
|
|
2
|
+
from simplibs.actions import Action
|
|
3
|
+
from simplibs.extractor import by_suffix
|
|
4
|
+
# Outers
|
|
5
|
+
from ..annotations import TemplateEngine
|
|
6
|
+
from ..constants import HTML_PLAIN_SUFFIXES, HTML_TEMPLATE_SUFFIXES, HTML_WRAPPED_SUFFIXES
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def steps_for_pages(make: Callable[[TemplateEngine | None], Action]) -> dict[str, Action]:
|
|
10
|
+
"""Give each kind of page its own steps: HTML as HTML, and the Jinja suffixes as Jinja.
|
|
11
|
+
|
|
12
|
+
Args:
|
|
13
|
+
make: A function from the engine to the steps (`html_clean_steps`...).
|
|
14
|
+
|
|
15
|
+
Returns:
|
|
16
|
+
A mapping `suffix -> step`, the form of `Profile.steps` that chooses by file type.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
# 1. `.html` and the like are pages; the suffixes of the Jinja family say what the engine is
|
|
20
|
+
return {
|
|
21
|
+
**by_suffix(make(None), HTML_PLAIN_SUFFIXES),
|
|
22
|
+
**by_suffix(make("jinja"), HTML_TEMPLATE_SUFFIXES + HTML_WRAPPED_SUFFIXES),
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
_DESIGN_NOTES = """
|
|
27
|
+
# steps_for_pages — The Engine Is Chosen by the Suffix
|
|
28
|
+
|
|
29
|
+
## Purpose
|
|
30
|
+
The profiles without an engine in their name read `.html` as a page that is
|
|
31
|
+
only HTML, because a `.html` file can be written for any engine or for none,
|
|
32
|
+
and a suffix of the Jinja family leaves no doubt.
|
|
33
|
+
|
|
34
|
+
## Not Exported
|
|
35
|
+
A tool of the profiles' own: it is not in `__all__` of the folder.
|
|
36
|
+
"""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|