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.
Files changed (127) hide show
  1. simplibs/extractor_html/__init__.py +82 -0
  2. simplibs/extractor_html/actions/ApplyToHtmlBlocks.py +29 -0
  3. simplibs/extractor_html/actions/CleanupHtmlWhitespace.py +22 -0
  4. simplibs/extractor_html/actions/CompactHtml.py +22 -0
  5. simplibs/extractor_html/actions/HtmlOutline.py +23 -0
  6. simplibs/extractor_html/actions/RemoveTemplateImports.py +22 -0
  7. simplibs/extractor_html/actions/StripHtmlComments.py +23 -0
  8. simplibs/extractor_html/actions/StripTemplateComments.py +27 -0
  9. simplibs/extractor_html/actions/TemplateOutline.py +23 -0
  10. simplibs/extractor_html/actions/__init__.py +57 -0
  11. simplibs/extractor_html/annotations/TemplateEngine.py +26 -0
  12. simplibs/extractor_html/annotations/__init__.py +14 -0
  13. simplibs/extractor_html/constants/HTML_ANY_TAG_PATTERN.py +16 -0
  14. simplibs/extractor_html/constants/HTML_BLOCK_LANGUAGE_BY_TYPE.py +41 -0
  15. simplibs/extractor_html/constants/HTML_COMMENT_END_PATTERN.py +19 -0
  16. simplibs/extractor_html/constants/HTML_CONDITIONAL_PATTERN.py +23 -0
  17. simplibs/extractor_html/constants/HTML_DEPENDENCY_DIR_NAMES.py +18 -0
  18. simplibs/extractor_html/constants/HTML_EXTRA_LANGUAGE_BY_SUFFIX.py +31 -0
  19. simplibs/extractor_html/constants/HTML_HEADING_ELEMENTS.py +15 -0
  20. simplibs/extractor_html/constants/HTML_ID_ATTRIBUTE_PATTERN.py +21 -0
  21. simplibs/extractor_html/constants/HTML_IMPLIED_END.py +34 -0
  22. simplibs/extractor_html/constants/HTML_LICENSE_START.py +14 -0
  23. simplibs/extractor_html/constants/HTML_LICENSE_TAGS.py +14 -0
  24. simplibs/extractor_html/constants/HTML_OUTLINE_ELEMENTS.py +32 -0
  25. simplibs/extractor_html/constants/HTML_OUTLINE_TEXT_LIMIT.py +15 -0
  26. simplibs/extractor_html/constants/HTML_OUTPUT_DIR_NAMES.py +43 -0
  27. simplibs/extractor_html/constants/HTML_PLAIN_SUFFIXES.py +18 -0
  28. simplibs/extractor_html/constants/HTML_RAW_TEXT_END_PATTERNS.py +28 -0
  29. simplibs/extractor_html/constants/HTML_SUFFIXES.py +22 -0
  30. simplibs/extractor_html/constants/HTML_TAG_NAME_PATTERN.py +16 -0
  31. simplibs/extractor_html/constants/HTML_TEMPLATE_BLOCKS.py +38 -0
  32. simplibs/extractor_html/constants/HTML_TEMPLATE_IMPORT_TAGS.py +29 -0
  33. simplibs/extractor_html/constants/HTML_TEMPLATE_OUTLINE_TAGS.py +35 -0
  34. simplibs/extractor_html/constants/HTML_TEMPLATE_SUFFIXES.py +19 -0
  35. simplibs/extractor_html/constants/HTML_TEMPLATE_TAG_NAME_PATTERN.py +16 -0
  36. simplibs/extractor_html/constants/HTML_TEMPLATE_TOKEN_PATTERN.py +16 -0
  37. simplibs/extractor_html/constants/HTML_TEXT_ELEMENTS.py +16 -0
  38. simplibs/extractor_html/constants/HTML_TOKEN_PATTERN.py +26 -0
  39. simplibs/extractor_html/constants/HTML_TYPE_ATTRIBUTE_PATTERN.py +21 -0
  40. simplibs/extractor_html/constants/HTML_VOID_ELEMENTS.py +21 -0
  41. simplibs/extractor_html/constants/HTML_WRAPPED_STEM_ENDING.py +14 -0
  42. simplibs/extractor_html/constants/HTML_WRAPPED_SUFFIXES.py +15 -0
  43. simplibs/extractor_html/constants/__init__.py +77 -0
  44. simplibs/extractor_html/file_rules/__init__.py +56 -0
  45. simplibs/extractor_html/file_rules/atomic/DEPENDENCY_DIRS.py +17 -0
  46. simplibs/extractor_html/file_rules/atomic/DOT_NAME.py +19 -0
  47. simplibs/extractor_html/file_rules/atomic/OUTPUT_DIRS.py +17 -0
  48. simplibs/extractor_html/file_rules/atomic/VCS_DIRS.py +21 -0
  49. simplibs/extractor_html/file_rules/atomic/WRAPPED_HTML.py +22 -0
  50. simplibs/extractor_html/file_rules/atomic/__init__.py +26 -0
  51. simplibs/extractor_html/file_rules/html/HTML_BASE.py +22 -0
  52. simplibs/extractor_html/file_rules/html/HTML_FILES.py +24 -0
  53. simplibs/extractor_html/file_rules/html/HTML_PLAIN_BASE.py +24 -0
  54. simplibs/extractor_html/file_rules/html/HTML_STRICT_EXCLUDE.py +21 -0
  55. simplibs/extractor_html/file_rules/html/__init__.py +20 -0
  56. simplibs/extractor_html/logic/__init__.py +44 -0
  57. simplibs/extractor_html/logic/_helpers/HtmlBlock.py +31 -0
  58. simplibs/extractor_html/logic/_helpers/HtmlOutlineBuilder.py +189 -0
  59. simplibs/extractor_html/logic/_helpers/HtmlScan.py +50 -0
  60. simplibs/extractor_html/logic/_helpers/HtmlTag.py +32 -0
  61. simplibs/extractor_html/logic/_helpers/Ranges.py +48 -0
  62. simplibs/extractor_html/logic/_helpers/TemplateScan.py +43 -0
  63. simplibs/extractor_html/logic/_helpers/TemplateTag.py +33 -0
  64. simplibs/extractor_html/logic/_helpers/__init__.py +68 -0
  65. simplibs/extractor_html/logic/_helpers/blank_spans.py +40 -0
  66. simplibs/extractor_html/logic/_helpers/build_html_outline.py +38 -0
  67. simplibs/extractor_html/logic/_helpers/build_template_outline.py +75 -0
  68. simplibs/extractor_html/logic/_helpers/find_blanks_start.py +29 -0
  69. simplibs/extractor_html/logic/_helpers/find_block_language.py +35 -0
  70. simplibs/extractor_html/logic/_helpers/find_comments.py +60 -0
  71. simplibs/extractor_html/logic/_helpers/find_protected_spans.py +48 -0
  72. simplibs/extractor_html/logic/_helpers/find_template_import_spans.py +37 -0
  73. simplibs/extractor_html/logic/_helpers/fit_removal_span.py +40 -0
  74. simplibs/extractor_html/logic/_helpers/is_license_comment.py +26 -0
  75. simplibs/extractor_html/logic/_helpers/line_of.py +23 -0
  76. simplibs/extractor_html/logic/_helpers/raise_block_result_invalid.py +38 -0
  77. simplibs/extractor_html/logic/_helpers/replace_spans.py +42 -0
  78. simplibs/extractor_html/logic/_helpers/scan_checked.py +45 -0
  79. simplibs/extractor_html/logic/_helpers/scan_html.py +208 -0
  80. simplibs/extractor_html/logic/_helpers/scan_templates.py +128 -0
  81. simplibs/extractor_html/logic/_helpers/scan_templates_checked.py +39 -0
  82. simplibs/extractor_html/logic/_helpers/skip_html_comment.py +41 -0
  83. simplibs/extractor_html/logic/_helpers/skip_html_tag.py +46 -0
  84. simplibs/extractor_html/logic/_helpers/tidy_lines.py +86 -0
  85. simplibs/extractor_html/logic/_helpers/warn_problems.py +32 -0
  86. simplibs/extractor_html/logic/apply_to_html_blocks.py +103 -0
  87. simplibs/extractor_html/logic/cleanup_html_whitespace.py +54 -0
  88. simplibs/extractor_html/logic/compact_html.py +44 -0
  89. simplibs/extractor_html/logic/html_comment_spans.py +54 -0
  90. simplibs/extractor_html/logic/html_outline.py +66 -0
  91. simplibs/extractor_html/logic/strip_html_comments.py +63 -0
  92. simplibs/extractor_html/logic/templates/__init__.py +25 -0
  93. simplibs/extractor_html/logic/templates/remove_template_imports.py +51 -0
  94. simplibs/extractor_html/logic/templates/strip_template_comments.py +60 -0
  95. simplibs/extractor_html/logic/templates/template_comment_spans.py +49 -0
  96. simplibs/extractor_html/logic/templates/template_outline.py +62 -0
  97. simplibs/extractor_html/plugin/__init__.py +14 -0
  98. simplibs/extractor_html/plugin/register_all.py +60 -0
  99. simplibs/extractor_html/presets/__init__.py +43 -0
  100. simplibs/extractor_html/presets/html_clean_steps.py +54 -0
  101. simplibs/extractor_html/presets/html_no_imports_steps.py +50 -0
  102. simplibs/extractor_html/presets/html_outline_steps.py +28 -0
  103. simplibs/extractor_html/presets/template_structure_steps.py +27 -0
  104. simplibs/extractor_html/profiles/DJANGO_CLEAN.py +36 -0
  105. simplibs/extractor_html/profiles/DJANGO_NO_IMPORTS.py +32 -0
  106. simplibs/extractor_html/profiles/DJANGO_OUTLINE.py +32 -0
  107. simplibs/extractor_html/profiles/DJANGO_STRUCTURE.py +32 -0
  108. simplibs/extractor_html/profiles/HTML_CODE_CLEAN.py +32 -0
  109. simplibs/extractor_html/profiles/HTML_CODE_NO_IMPORTS.py +30 -0
  110. simplibs/extractor_html/profiles/HTML_DATA_ALL.py +26 -0
  111. simplibs/extractor_html/profiles/HTML_OUTLINE.py +31 -0
  112. simplibs/extractor_html/profiles/HTML_PROFILES.py +42 -0
  113. simplibs/extractor_html/profiles/HTML_SRC_CLEAN.py +31 -0
  114. simplibs/extractor_html/profiles/JINJA_CLEAN.py +35 -0
  115. simplibs/extractor_html/profiles/JINJA_NO_IMPORTS.py +32 -0
  116. simplibs/extractor_html/profiles/JINJA_OUTLINE.py +30 -0
  117. simplibs/extractor_html/profiles/JINJA_STRUCTURE.py +31 -0
  118. simplibs/extractor_html/profiles/__init__.py +86 -0
  119. simplibs/extractor_html/profiles/steps_for_engine.py +39 -0
  120. simplibs/extractor_html/profiles/steps_for_pages.py +36 -0
  121. simplibs/extractor_html/py.typed +1 -0
  122. simplibs_extractor_html-0.1.0.dist-info/METADATA +504 -0
  123. simplibs_extractor_html-0.1.0.dist-info/RECORD +127 -0
  124. simplibs_extractor_html-0.1.0.dist-info/WHEEL +5 -0
  125. simplibs_extractor_html-0.1.0.dist-info/entry_points.txt +2 -0
  126. simplibs_extractor_html-0.1.0.dist-info/licenses/LICENSE +21 -0
  127. simplibs_extractor_html-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,54 @@
1
+ from simplibs.actions import Action
2
+ from simplibs.extractor_css.presets import CSS_PLAIN_CLEAN
3
+ from simplibs.extractor_javascript.presets import JS_CLEAN
4
+ # Outers
5
+ from ..actions import ApplyToHtmlBlocks, CleanupHtmlWhitespace, StripHtmlComments, StripTemplateComments
6
+ from ..annotations import TemplateEngine
7
+
8
+
9
+ def html_clean_steps(engine: TemplateEngine | None) -> Action:
10
+ """Build the steps that clean a page: the comments out, the code inside it cleaned, the whitespace tidied.
11
+
12
+ Args:
13
+ engine: The template language of the page; `None` for a page that is only HTML.
14
+
15
+ Returns:
16
+ The pipeline. Imports stay.
17
+ """
18
+
19
+ # 1. The comments of the page, and for a template its own comments as well
20
+ steps = StripHtmlComments(engine=engine)
21
+ if engine is not None:
22
+ steps = steps >> StripTemplateComments(engine=engine)
23
+
24
+ # 2. The code inside the page, then the page itself
25
+ return (
26
+ steps
27
+ >> ApplyToHtmlBlocks(script=JS_CLEAN, style=CSS_PLAIN_CLEAN, engine=engine)
28
+ >> CleanupHtmlWhitespace(engine=engine)
29
+ )
30
+
31
+
32
+ _DESIGN_NOTES = """
33
+ # html_clean_steps — The Everyday Clean Read of a Page
34
+
35
+ ## Purpose
36
+ The steps of the profiles that clean pages and templates, for one engine.
37
+
38
+ ## Order
39
+ 1. The comments of the page, then the comments of the template: a template
40
+ comment inside an HTML comment is gone with it, and an HTML comment inside
41
+ a template comment is gone with that.
42
+ 2. The code inside the page. It comes after the comments, so a `{# note #}`
43
+ inside a `<script>` is not left for the JavaScript step to see.
44
+ 3. The whitespace of the page, last, as the steps before it leave blank lines.
45
+
46
+ ## Why a Function and Not a Constant
47
+ A preset of the other add-ons is built once. Here it differs only in the
48
+ engine, and three constants that differ in one argument would say the same
49
+ thing three times.
50
+
51
+ ## The Code Inside
52
+ The JavaScript is cleaned by `JS_CLEAN` of `simplibs-extractor-javascript`, the
53
+ CSS by `CSS_PLAIN_CLEAN` of `simplibs-extractor-css`: a `<style>` is plain CSS.
54
+ """
@@ -0,0 +1,50 @@
1
+ from simplibs.actions import Action
2
+ from simplibs.extractor_css.presets import CSS_PLAIN_NO_IMPORTS
3
+ from simplibs.extractor_javascript.presets import JS_NO_IMPORTS
4
+ # Outers
5
+ from ..actions import (
6
+ ApplyToHtmlBlocks,
7
+ CompactHtml,
8
+ RemoveTemplateImports,
9
+ StripHtmlComments,
10
+ StripTemplateComments,
11
+ )
12
+ from ..annotations import TemplateEngine
13
+
14
+
15
+ def html_no_imports_steps(engine: TemplateEngine | None) -> Action:
16
+ """Build the steps that reduce a page to its content: no comments, no imports, no blank lines.
17
+
18
+ Args:
19
+ engine: The template language of the page; `None` for a page that is only HTML.
20
+
21
+ Returns:
22
+ The pipeline.
23
+ """
24
+
25
+ # 1. The comments of the page, and for a template its own comments and its imports
26
+ steps = StripHtmlComments(engine=engine)
27
+ if engine is not None:
28
+ steps = steps >> StripTemplateComments(engine=engine) >> RemoveTemplateImports(engine=engine)
29
+
30
+ # 2. The code inside the page without its imports, then the page itself without blank lines
31
+ return (
32
+ steps
33
+ >> ApplyToHtmlBlocks(script=JS_NO_IMPORTS, style=CSS_PLAIN_NO_IMPORTS, engine=engine)
34
+ >> CompactHtml(engine=engine)
35
+ )
36
+
37
+
38
+ _DESIGN_NOTES = """
39
+ # html_no_imports_steps — The Page and Nothing Around It
40
+
41
+ ## Purpose
42
+ The steps of the profiles without imports. A page itself has no imports; what
43
+ it has is the code inside it (`import` in a module script, `@import` in a
44
+ style) and, for a template, the tags that bring in names (`{% load %}`,
45
+ `{% import %}`). All of them go.
46
+
47
+ ## Order
48
+ The same as for the clean steps: comments first, then the imports of the
49
+ template, then the code inside the page, and the blank lines last.
50
+ """
@@ -0,0 +1,28 @@
1
+ from simplibs.actions import Action
2
+ # Outers
3
+ from ..actions import HtmlOutline
4
+ from ..annotations import TemplateEngine
5
+
6
+
7
+ def html_outline_steps(engine: TemplateEngine | None) -> Action:
8
+ """Build the step that gives an overview of a page.
9
+
10
+ Args:
11
+ engine: The template language of the page; `None` for a page that is only HTML.
12
+
13
+ Returns:
14
+ The step.
15
+ """
16
+
17
+ # 1. One action; the engine only tells it how to read the page
18
+ return HtmlOutline(engine=engine)
19
+
20
+
21
+ _DESIGN_NOTES = """
22
+ # html_outline_steps — What a Page Is Made Of
23
+
24
+ ## Purpose
25
+ The step of the profiles with an overview of the page. A single action, and a
26
+ preset all the same: every profile asks for its steps by the engine, in the
27
+ same way.
28
+ """
@@ -0,0 +1,27 @@
1
+ from simplibs.actions import Action
2
+ # Outers
3
+ from ..actions import TemplateOutline
4
+ from ..annotations import TemplateEngine
5
+
6
+
7
+ def template_structure_steps(engine: TemplateEngine) -> Action:
8
+ """Build the step that gives the skeleton of a template: its `extends`, `include` and blocks.
9
+
10
+ Args:
11
+ engine: `"django"` or `"jinja"`.
12
+
13
+ Returns:
14
+ The step.
15
+ """
16
+
17
+ # 1. One action; a template cannot be read without knowing its engine
18
+ return TemplateOutline(engine=engine)
19
+
20
+
21
+ _DESIGN_NOTES = """
22
+ # template_structure_steps — What a Template Is Built Of
23
+
24
+ ## Purpose
25
+ The step of the profiles with the skeleton of a template. The engine is
26
+ required, as in the action.
27
+ """
@@ -0,0 +1,36 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_PLAIN_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import html_clean_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ DJANGO_CLEAN: Final[Profile] = Profile(
11
+ system="html",
12
+ name="django-clean",
13
+ description="Django templates without HTML and template comments and extra blank lines (imports stay)",
14
+ include=HTML_PLAIN_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(html_clean_steps, "django"),
17
+ output_name="html_django_clean.md",
18
+ )
19
+ """The profile `html/django-clean`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # DJANGO_CLEAN — `html/django-clean`
24
+
25
+ ## Purpose
26
+ The templates of a Django project, read as templates: `{# #}` and
27
+ `{% comment %}` go with the HTML comments, and `{% if a > b %}` or `{{ x }}`
28
+ inside a tag cannot confuse the reading of the page.
29
+
30
+ ## Strict
31
+ It leaves out packages and generated output (`staticfiles` among them), as a
32
+ project of templates has no reason to read them.
33
+
34
+ ## Output
35
+ `html_django_clean.md`.
36
+ """
@@ -0,0 +1,32 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_PLAIN_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import html_no_imports_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ DJANGO_NO_IMPORTS: Final[Profile] = Profile(
11
+ system="html",
12
+ name="django-no-imports",
13
+ description="Django templates reduced to their content: no comments, {% load %}, imports in script and style, or blank lines",
14
+ include=HTML_PLAIN_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(html_no_imports_steps, "django"),
17
+ output_name="html_django_no_imports.md",
18
+ )
19
+ """The profile `html/django-no-imports`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # DJANGO_NO_IMPORTS — `html/django-no-imports`
24
+
25
+ ## Purpose
26
+ The Django templates without what only says where names come from: the
27
+ `{% load %}` tags and the imports of the code inside. `{% extends %}` and
28
+ `{% include %}` stay: they say what a page is made of.
29
+
30
+ ## Output
31
+ `html_django_no_imports.md`.
32
+ """
@@ -0,0 +1,32 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_PLAIN_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import html_outline_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ DJANGO_OUTLINE: Final[Profile] = Profile(
11
+ system="html",
12
+ name="django-outline",
13
+ description="Overview of Django templates as pages: landmarks, headings and every element with an id",
14
+ include=HTML_PLAIN_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(html_outline_steps, "django"),
17
+ output_name="html_django_outline.md",
18
+ )
19
+ """The profile `html/django-outline`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # DJANGO_OUTLINE — `html/django-outline`
24
+
25
+ ## Purpose
26
+ The overview of the pages of a Django project, read as templates: an `id` or a
27
+ heading that holds `{{ title }}` is written as it stands, and a condition with
28
+ `>` inside a tag does not hide the rest of the page.
29
+
30
+ ## Output
31
+ `html_django_outline.md`.
32
+ """
@@ -0,0 +1,32 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_PLAIN_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import template_structure_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ DJANGO_STRUCTURE: Final[Profile] = Profile(
11
+ system="html",
12
+ name="django-structure",
13
+ description="Skeleton of Django templates: extends, include and blocks",
14
+ include=HTML_PLAIN_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(template_structure_steps, "django"),
17
+ output_name="html_django_structure.md",
18
+ )
19
+ """The profile `html/django-structure`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # DJANGO_STRUCTURE — `html/django-structure`
24
+
25
+ ## Purpose
26
+ How the templates of a Django project are put together: which one extends which,
27
+ what they include and which blocks they define, in a few lines for each. A file
28
+ with none of those tags gives an empty section.
29
+
30
+ ## Output
31
+ `html_django_structure.md`.
32
+ """
@@ -0,0 +1,32 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE
5
+ from ..presets import html_clean_steps
6
+ # Inners
7
+ from .steps_for_pages import steps_for_pages
8
+
9
+
10
+ HTML_CODE_CLEAN: Final[Profile] = Profile(
11
+ system="html",
12
+ name="code-clean",
13
+ description="Pages without comments and extra blank lines, the code inside cleaned too (imports stay)",
14
+ include=HTML_BASE,
15
+ steps=steps_for_pages(html_clean_steps),
16
+ output_name="html_code_clean.md",
17
+ )
18
+ """The profile `html/code-clean`."""
19
+
20
+
21
+ _DESIGN_NOTES = """
22
+ # HTML_CODE_CLEAN — `html/code-clean`
23
+
24
+ ## Purpose
25
+ Every page of the project with the comments taken out and the whitespace
26
+ tidied, as it is otherwise: the everyday way to give a page to a reader. The
27
+ JavaScript and CSS inside it are cleaned by the steps of their own add-ons.
28
+
29
+ ## Output
30
+ `html_code_clean.md`. `.html` is read as a page without a template engine, the
31
+ suffixes of the Jinja family as Jinja.
32
+ """
@@ -0,0 +1,30 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE
5
+ from ..presets import html_no_imports_steps
6
+ # Inners
7
+ from .steps_for_pages import steps_for_pages
8
+
9
+
10
+ HTML_CODE_NO_IMPORTS: Final[Profile] = Profile(
11
+ system="html",
12
+ name="code-no-imports",
13
+ description="Pure content: no comments, imports (also inside script and style) or blank lines",
14
+ include=HTML_BASE,
15
+ steps=steps_for_pages(html_no_imports_steps),
16
+ output_name="html_code_no_imports.md",
17
+ )
18
+ """The profile `html/code-no-imports`."""
19
+
20
+
21
+ _DESIGN_NOTES = """
22
+ # HTML_CODE_NO_IMPORTS — `html/code-no-imports`
23
+
24
+ ## Purpose
25
+ The pages reduced to what they say: no comments, no imports of the code inside
26
+ (and of the template, for a Jinja suffix), no blank lines.
27
+
28
+ ## Output
29
+ `html_code_no_imports.md`.
30
+ """
@@ -0,0 +1,26 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE
5
+
6
+
7
+ HTML_DATA_ALL: Final[Profile] = Profile(
8
+ system="html",
9
+ name="data-all",
10
+ description="Every relevant page, as it is",
11
+ include=HTML_BASE,
12
+ output_name="html_data_all.md",
13
+ )
14
+ """The profile `html/data-all`."""
15
+
16
+
17
+ _DESIGN_NOTES = """
18
+ # HTML_DATA_ALL — `html/data-all`
19
+
20
+ ## Purpose
21
+ The files selected by `HTML_BASE`, untouched: comments, imports and generated
22
+ pages included.
23
+
24
+ ## Output
25
+ `html_data_all.md`.
26
+ """
@@ -0,0 +1,31 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE
5
+ from ..presets import html_outline_steps
6
+ # Inners
7
+ from .steps_for_pages import steps_for_pages
8
+
9
+
10
+ HTML_OUTLINE: Final[Profile] = Profile(
11
+ system="html",
12
+ name="outline",
13
+ description="Overview of the pages: landmarks, headings and every element with an id",
14
+ include=HTML_BASE,
15
+ steps=steps_for_pages(html_outline_steps),
16
+ output_name="html_outline.md",
17
+ )
18
+ """The profile `html/outline`."""
19
+
20
+
21
+ _DESIGN_NOTES = """
22
+ # HTML_OUTLINE — `html/outline`
23
+
24
+ ## Purpose
25
+ What a project's pages are made of, in a fraction of their size: for a reader
26
+ with a limited window, the map of the pages.
27
+
28
+ ## Output
29
+ `html_outline.md`; each file is a list of elements, one per line, indented by
30
+ depth.
31
+ """
@@ -0,0 +1,42 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Inners
4
+ from .DJANGO_CLEAN import DJANGO_CLEAN
5
+ from .DJANGO_NO_IMPORTS import DJANGO_NO_IMPORTS
6
+ from .DJANGO_OUTLINE import DJANGO_OUTLINE
7
+ from .DJANGO_STRUCTURE import DJANGO_STRUCTURE
8
+ from .HTML_CODE_CLEAN import HTML_CODE_CLEAN
9
+ from .HTML_CODE_NO_IMPORTS import HTML_CODE_NO_IMPORTS
10
+ from .HTML_DATA_ALL import HTML_DATA_ALL
11
+ from .HTML_OUTLINE import HTML_OUTLINE
12
+ from .HTML_SRC_CLEAN import HTML_SRC_CLEAN
13
+ from .JINJA_CLEAN import JINJA_CLEAN
14
+ from .JINJA_NO_IMPORTS import JINJA_NO_IMPORTS
15
+ from .JINJA_OUTLINE import JINJA_OUTLINE
16
+ from .JINJA_STRUCTURE import JINJA_STRUCTURE
17
+
18
+
19
+ HTML_PROFILES: Final[tuple[Profile, ...]] = (
20
+ DJANGO_CLEAN,
21
+ DJANGO_NO_IMPORTS,
22
+ DJANGO_OUTLINE,
23
+ DJANGO_STRUCTURE,
24
+ HTML_CODE_CLEAN,
25
+ HTML_CODE_NO_IMPORTS,
26
+ HTML_DATA_ALL,
27
+ HTML_OUTLINE,
28
+ HTML_SRC_CLEAN,
29
+ JINJA_CLEAN,
30
+ JINJA_NO_IMPORTS,
31
+ JINJA_OUTLINE,
32
+ JINJA_STRUCTURE,
33
+ )
34
+ """The profiles of the system `html`."""
35
+
36
+
37
+ _DESIGN_NOTES = """
38
+ # HTML_PROFILES — The `html` System
39
+
40
+ ## Purpose
41
+ The profiles of one system in the order the listing commands show them.
42
+ """
@@ -0,0 +1,31 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import html_clean_steps
6
+ # Inners
7
+ from .steps_for_pages import steps_for_pages
8
+
9
+
10
+ HTML_SRC_CLEAN: Final[Profile] = Profile(
11
+ system="html",
12
+ name="src-clean",
13
+ description="Like code-clean, without packages of other people and generated pages",
14
+ include=HTML_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_pages(html_clean_steps),
17
+ output_name="html_src_clean.md",
18
+ )
19
+ """The profile `html/src-clean`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # HTML_SRC_CLEAN — `html/src-clean`
24
+
25
+ ## Purpose
26
+ Only the project's own pages, cleaned: no `node_modules` or `vendor`, no `dist`,
27
+ `_build` or `staticfiles`, no coverage reports.
28
+
29
+ ## Output
30
+ `html_src_clean.md`.
31
+ """
@@ -0,0 +1,35 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import html_clean_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ JINJA_CLEAN: Final[Profile] = Profile(
11
+ system="html",
12
+ name="jinja-clean",
13
+ description="Jinja templates without HTML and template comments and extra blank lines (imports stay)",
14
+ include=HTML_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(html_clean_steps, "jinja"),
17
+ output_name="html_jinja_clean.md",
18
+ )
19
+ """The profile `html/jinja-clean`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # JINJA_CLEAN — `html/jinja-clean`
24
+
25
+ ## Purpose
26
+ The templates of a Jinja (or Nunjucks) project, read as templates: `{# ... #}`,
27
+ which may span lines, goes with the HTML comments, and `{% raw %}` is left
28
+ alone.
29
+
30
+ ## Strict
31
+ It leaves out packages and generated output.
32
+
33
+ ## Output
34
+ `html_jinja_clean.md`.
35
+ """
@@ -0,0 +1,32 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import html_no_imports_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ JINJA_NO_IMPORTS: Final[Profile] = Profile(
11
+ system="html",
12
+ name="jinja-no-imports",
13
+ description="Jinja templates reduced to their content: no comments, {% import %} and {% from %}, imports in script and style, or blank lines",
14
+ include=HTML_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(html_no_imports_steps, "jinja"),
17
+ output_name="html_jinja_no_imports.md",
18
+ )
19
+ """The profile `html/jinja-no-imports`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # JINJA_NO_IMPORTS — `html/jinja-no-imports`
24
+
25
+ ## Purpose
26
+ The Jinja templates without what only says where macros come from
27
+ (`{% import %}`, `{% from %}`) and without the imports of the code inside.
28
+ `{% extends %}` and `{% include %}` stay.
29
+
30
+ ## Output
31
+ `html_jinja_no_imports.md`.
32
+ """
@@ -0,0 +1,30 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import html_outline_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ JINJA_OUTLINE: Final[Profile] = Profile(
11
+ system="html",
12
+ name="jinja-outline",
13
+ description="Overview of Jinja templates as pages: landmarks, headings and every element with an id",
14
+ include=HTML_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(html_outline_steps, "jinja"),
17
+ output_name="html_jinja_outline.md",
18
+ )
19
+ """The profile `html/jinja-outline`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # JINJA_OUTLINE — `html/jinja-outline`
24
+
25
+ ## Purpose
26
+ The overview of the pages of a Jinja project, read as templates.
27
+
28
+ ## Output
29
+ `html_jinja_outline.md`.
30
+ """
@@ -0,0 +1,31 @@
1
+ from typing import Final
2
+ from simplibs.extractor import Profile
3
+ # Outers
4
+ from ..file_rules import HTML_BASE, HTML_STRICT_EXCLUDE
5
+ from ..presets import template_structure_steps
6
+ # Inners
7
+ from .steps_for_engine import steps_for_engine
8
+
9
+
10
+ JINJA_STRUCTURE: Final[Profile] = Profile(
11
+ system="html",
12
+ name="jinja-structure",
13
+ description="Skeleton of Jinja templates: extends, include, macros and blocks",
14
+ include=HTML_BASE,
15
+ exclude=HTML_STRICT_EXCLUDE,
16
+ steps=steps_for_engine(template_structure_steps, "jinja"),
17
+ output_name="html_jinja_structure.md",
18
+ )
19
+ """The profile `html/jinja-structure`."""
20
+
21
+
22
+ _DESIGN_NOTES = """
23
+ # JINJA_STRUCTURE — `html/jinja-structure`
24
+
25
+ ## Purpose
26
+ How the templates of a Jinja project are put together: what each extends and
27
+ includes, which macros it defines and which blocks it has.
28
+
29
+ ## Output
30
+ `html_jinja_structure.md`.
31
+ """