rb-html-to-gutenberg 0.5.6__tar.gz

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 (73) hide show
  1. rb_html_to_gutenberg-0.5.6/.gitignore +20 -0
  2. rb_html_to_gutenberg-0.5.6/LICENSE +21 -0
  3. rb_html_to_gutenberg-0.5.6/PKG-INFO +135 -0
  4. rb_html_to_gutenberg-0.5.6/README.md +116 -0
  5. rb_html_to_gutenberg-0.5.6/pyproject.toml +165 -0
  6. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/__init__.py +5 -0
  7. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/_distribution.py +24 -0
  8. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/cli.py +69 -0
  9. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/__init__.py +1 -0
  10. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/auth.py +66 -0
  11. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/config.py +87 -0
  12. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/convert.py +44 -0
  13. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/describe.py +34 -0
  14. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/doctor.py +43 -0
  15. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/init.py +48 -0
  16. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/project.py +55 -0
  17. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/skill.py +138 -0
  18. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/commands/status.py +35 -0
  19. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/__init__.py +1 -0
  20. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/converter.py +215 -0
  21. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/data_files.py +20 -0
  22. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/deps.py +165 -0
  23. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/errors.py +215 -0
  24. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/models.py +25 -0
  25. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/opencli.py +285 -0
  26. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/services.py +95 -0
  27. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/skills.py +64 -0
  28. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/core/version.py +89 -0
  29. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/data/SKILL.md +64 -0
  30. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/data/__init__.py +1 -0
  31. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/output/__init__.py +281 -0
  32. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/output/human.py +34 -0
  33. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/output/json.py +11 -0
  34. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/providers/__init__.py +29 -0
  35. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/providers/base.py +137 -0
  36. rb_html_to_gutenberg-0.5.6/src/rb_html_to_gutenberg/providers/http.py +124 -0
  37. rb_html_to_gutenberg-0.5.6/tests/__init__.py +1 -0
  38. rb_html_to_gutenberg-0.5.6/tests/conftest.py +29 -0
  39. rb_html_to_gutenberg-0.5.6/tests/contracts/fixtures.yaml +11 -0
  40. rb_html_to_gutenberg-0.5.6/tests/contracts/schema.json +89 -0
  41. rb_html_to_gutenberg-0.5.6/tests/contracts/tools-catalog/html-to-gutenberg.yaml +20 -0
  42. rb_html_to_gutenberg-0.5.6/tests/data/contracts/windmill-serp.yaml +106 -0
  43. rb_html_to_gutenberg-0.5.6/tests/data/opencli.schema.json +350 -0
  44. rb_html_to_gutenberg-0.5.6/tests/help_allowlist.txt +3 -0
  45. rb_html_to_gutenberg-0.5.6/tests/snapshots/describe.json +924 -0
  46. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/auth-status.txt +26 -0
  47. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/auth.txt +13 -0
  48. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/config-get.txt +16 -0
  49. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/config-list.txt +13 -0
  50. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/config-set.txt +17 -0
  51. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/config.txt +14 -0
  52. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/convert.txt +28 -0
  53. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/describe.txt +18 -0
  54. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/doctor.txt +17 -0
  55. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/init.txt +16 -0
  56. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/skill-install.txt +18 -0
  57. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/skill-list.txt +13 -0
  58. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/skill.txt +13 -0
  59. rb_html_to_gutenberg-0.5.6/tests/snapshots/help/status.txt +14 -0
  60. rb_html_to_gutenberg-0.5.6/tests/test_cli.py +359 -0
  61. rb_html_to_gutenberg-0.5.6/tests/test_contract_runner.py +257 -0
  62. rb_html_to_gutenberg-0.5.6/tests/test_contracts.py +389 -0
  63. rb_html_to_gutenberg-0.5.6/tests/test_converter.py +159 -0
  64. rb_html_to_gutenberg-0.5.6/tests/test_deps.py +150 -0
  65. rb_html_to_gutenberg-0.5.6/tests/test_describe.py +181 -0
  66. rb_html_to_gutenberg-0.5.6/tests/test_detach.py +161 -0
  67. rb_html_to_gutenberg-0.5.6/tests/test_help.py +497 -0
  68. rb_html_to_gutenberg-0.5.6/tests/test_http_provider.py +114 -0
  69. rb_html_to_gutenberg-0.5.6/tests/test_project.py +155 -0
  70. rb_html_to_gutenberg-0.5.6/tests/test_providers.py +69 -0
  71. rb_html_to_gutenberg-0.5.6/tests/test_scripts.py +54 -0
  72. rb_html_to_gutenberg-0.5.6/tests/test_services.py +50 -0
  73. rb_html_to_gutenberg-0.5.6/tests/test_skills.py +181 -0
@@ -0,0 +1,20 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ .venv/
4
+ .pytest_cache/
5
+ .ruff_cache/
6
+ dist/
7
+ *.egg-info/
8
+ .python-version
9
+ .coverage
10
+ htmlcov/
11
+ # mutmut's working copy and results (uv run --group mutation mutmut run)
12
+ mutants/
13
+ # Local env files hold keys: keys never go into the repo (the gate's secret scan)
14
+ .env
15
+ .env.*
16
+ # The root lines Antagor adds
17
+ .DS_Store
18
+ Thumbs.db
19
+ .pdm-build/
20
+ .cache/
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Roman Bolandau
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.5
2
+ Name: rb-html-to-gutenberg
3
+ Version: 0.5.6
4
+ Summary: Convert HTML into WordPress Gutenberg blocks.
5
+ Project-URL: Repository, https://github.com/bolandeu/html-to-gutenberg
6
+ Author: bolandeu
7
+ License-Expression: MIT
8
+ License-File: LICENSE
9
+ Requires-Python: >=3.14
10
+ Requires-Dist: beautifulsoup4>=4.12
11
+ Requires-Dist: httpx>=0.27
12
+ Requires-Dist: packaging>=24.0
13
+ Requires-Dist: platformdirs>=4.2
14
+ Requires-Dist: pydantic>=2.6
15
+ Requires-Dist: rich>=13.7
16
+ Requires-Dist: tomli-w>=1.0
17
+ Requires-Dist: typer<0.29,>=0.27
18
+ Description-Content-Type: text/markdown
19
+
20
+ # html-to-gutenberg
21
+
22
+ Конвертация HTML в WordPress Gutenberg блоки — Python-библиотека и CLI
23
+
24
+ ## Usage
25
+
26
+ **CLI** (for humans and agents; `html-to-gutenberg` and `html_to_gutenberg` are the same command):
27
+
28
+ ```bash
29
+ html-to-gutenberg convert page.html # markup to stdout
30
+ html-to-gutenberg convert page.html -o out.html # write to a file
31
+ html-to-gutenberg convert page.html --json # {"ok": true, "blocks": "...", "output": null}
32
+ ```
33
+
34
+ Wrappers like `div`/`section` are unwrapped, tags without a native block
35
+ are kept as Custom HTML (`wp:html`), `script`/`style`/`head` are dropped —
36
+ each such case is a warning (stderr; `"warnings"` under `--json`), so
37
+ nothing disappears silently. `html-to-gutenberg convert --help` lists the
38
+ native blocks.
39
+
40
+ **Python library:**
41
+
42
+ ```python
43
+ from rb_html_to_gutenberg import HtmlToGutenberg
44
+
45
+ blocks = HtmlToGutenberg().convert("<h2>Title</h2><p>Text</p>")
46
+ report = HtmlToGutenberg().convert_report(html) # report.blocks, report.warnings
47
+ ```
48
+
49
+ In another uv project, depend on it editable (edits here are picked up
50
+ immediately) or from Gitea:
51
+
52
+ ```bash
53
+ uv add --editable /Users/bolandau/Work/tools/rb-html-to-gutenberg
54
+ uv add "rb-html-to-gutenberg @ git+https://homeserver.tailee01ab.ts.net:3000/bolandeu/html-to-gutenberg.git@vX.Y.Z"
55
+ ```
56
+
57
+ The distribution is `rb-html-to-gutenberg` (standard §10); the import package
58
+ (`html_to_gutenberg`) and the command (`html-to-gutenberg`) keep their names.
59
+ Pin a tag (`@vX.Y.Z`) rather than a branch.
60
+
61
+ ## Development
62
+
63
+ ```bash
64
+ uv sync
65
+ uv run html-to-gutenberg --help
66
+ uv run pytest --snapshot-update # after changing a command's help; review tests/snapshots/help/
67
+ ```
68
+
69
+ The gate is `gate check`, run on this machine before a commit.
70
+ the changelog and the release are Antagor's (`antagor board`, `antagor publish`); the version is the git tag
71
+ (`vX.Y.Z`), `pyproject.toml` has no `version =`.
72
+
73
+ ## Install
74
+
75
+ **On this machine, from a local checkout** — editable, so code edits take
76
+ effect in the global command without reinstalling:
77
+
78
+ ```bash
79
+ uv tool install --editable .
80
+ ```
81
+
82
+ **From the Gitea registry** (the package is released there):
83
+
84
+ ```bash
85
+ uv tool uninstall html_to_gutenberg # once: the old distribution name (before v0.4.0)
86
+ ```
87
+
88
+ **From the git tag** (any machine, any OS):
89
+
90
+ ```bash
91
+ uv tool install "rb-html-to-gutenberg @ git+https://homeserver.tailee01ab.ts.net:3000/bolandeu/html-to-gutenberg.git@vX.Y.Z"
92
+ ```
93
+
94
+ `vX.Y.Z` is a release tag cut by `antagor publish`. Uninstall the old
95
+ `html_to_gutenberg` tool first, otherwise two tools fight over the same command. This is also how an AI agent
96
+ bootstraps this CLI on a fresh machine/sandbox where it isn't installed
97
+ yet — see `src/rb_html_to_gutenberg/data/SKILL.md`.
98
+
99
+ **Update** an installed copy to the latest commit:
100
+
101
+ ```bash
102
+ uv tool upgrade rb-html-to-gutenberg
103
+ ```
104
+
105
+ After install, the command `html_to_gutenberg` is available globally, on
106
+ macOS, Linux and Windows alike (see `architecture.md` in the cli-generator
107
+ plugin for why: no shelling out, no hardcoded POSIX paths).
108
+
109
+ To pick up later template changes, see `existing-package.md` in the `cli-generator` plugin (`copier update`).
110
+
111
+ ## Architecture
112
+
113
+ This project follows a fixed CLI architecture:
114
+
115
+ - `src/rb_html_to_gutenberg/commands/` — argument parsing only, no business logic.
116
+ - `src/rb_html_to_gutenberg/core/` — services, models, errors: the real logic.
117
+ - `src/rb_html_to_gutenberg/providers/` — external APIs/integrations.
118
+ - `src/rb_html_to_gutenberg/credentials/` — secrets via the OS keychain (`keyring`)
119
+ and environment variables. Secrets never live in `.html_to_gutenberg/config.toml`.
120
+ - `src/rb_html_to_gutenberg/output/` — human (`rich`) and `--json` rendering.
121
+
122
+ Run `html_to_gutenberg doctor` to check environment/config/auth readiness, and
123
+ `html_to_gutenberg --help` for the full command surface. Every command supports
124
+ `--json` for machine/agent consumption; errors are structured (`error.code`,
125
+ fixed exit codes, `error.action` telling you what to do next) and go to
126
+ stderr in human mode, so stdout is always safe to pipe.
127
+
128
+ A project can require a minimum CLI version in its `.html_to_gutenberg/config.toml`
129
+ (`[cli] min_version = "..."`); an older install refuses with exit 6 and
130
+ `uv tool upgrade rb-html-to-gutenberg` fixes it.
131
+
132
+ See `src/rb_html_to_gutenberg/data/SKILL.md` for the agent-facing usage guide
133
+ bundled with this package — install it into an AI tool with
134
+ `html_to_gutenberg skill install`, or get it as plain text with
135
+ `html_to_gutenberg --ai` (works even without file access).
@@ -0,0 +1,116 @@
1
+ # html-to-gutenberg
2
+
3
+ Конвертация HTML в WordPress Gutenberg блоки — Python-библиотека и CLI
4
+
5
+ ## Usage
6
+
7
+ **CLI** (for humans and agents; `html-to-gutenberg` and `html_to_gutenberg` are the same command):
8
+
9
+ ```bash
10
+ html-to-gutenberg convert page.html # markup to stdout
11
+ html-to-gutenberg convert page.html -o out.html # write to a file
12
+ html-to-gutenberg convert page.html --json # {"ok": true, "blocks": "...", "output": null}
13
+ ```
14
+
15
+ Wrappers like `div`/`section` are unwrapped, tags without a native block
16
+ are kept as Custom HTML (`wp:html`), `script`/`style`/`head` are dropped —
17
+ each such case is a warning (stderr; `"warnings"` under `--json`), so
18
+ nothing disappears silently. `html-to-gutenberg convert --help` lists the
19
+ native blocks.
20
+
21
+ **Python library:**
22
+
23
+ ```python
24
+ from rb_html_to_gutenberg import HtmlToGutenberg
25
+
26
+ blocks = HtmlToGutenberg().convert("<h2>Title</h2><p>Text</p>")
27
+ report = HtmlToGutenberg().convert_report(html) # report.blocks, report.warnings
28
+ ```
29
+
30
+ In another uv project, depend on it editable (edits here are picked up
31
+ immediately) or from Gitea:
32
+
33
+ ```bash
34
+ uv add --editable /Users/bolandau/Work/tools/rb-html-to-gutenberg
35
+ uv add "rb-html-to-gutenberg @ git+https://homeserver.tailee01ab.ts.net:3000/bolandeu/html-to-gutenberg.git@vX.Y.Z"
36
+ ```
37
+
38
+ The distribution is `rb-html-to-gutenberg` (standard §10); the import package
39
+ (`html_to_gutenberg`) and the command (`html-to-gutenberg`) keep their names.
40
+ Pin a tag (`@vX.Y.Z`) rather than a branch.
41
+
42
+ ## Development
43
+
44
+ ```bash
45
+ uv sync
46
+ uv run html-to-gutenberg --help
47
+ uv run pytest --snapshot-update # after changing a command's help; review tests/snapshots/help/
48
+ ```
49
+
50
+ The gate is `gate check`, run on this machine before a commit.
51
+ the changelog and the release are Antagor's (`antagor board`, `antagor publish`); the version is the git tag
52
+ (`vX.Y.Z`), `pyproject.toml` has no `version =`.
53
+
54
+ ## Install
55
+
56
+ **On this machine, from a local checkout** — editable, so code edits take
57
+ effect in the global command without reinstalling:
58
+
59
+ ```bash
60
+ uv tool install --editable .
61
+ ```
62
+
63
+ **From the Gitea registry** (the package is released there):
64
+
65
+ ```bash
66
+ uv tool uninstall html_to_gutenberg # once: the old distribution name (before v0.4.0)
67
+ ```
68
+
69
+ **From the git tag** (any machine, any OS):
70
+
71
+ ```bash
72
+ uv tool install "rb-html-to-gutenberg @ git+https://homeserver.tailee01ab.ts.net:3000/bolandeu/html-to-gutenberg.git@vX.Y.Z"
73
+ ```
74
+
75
+ `vX.Y.Z` is a release tag cut by `antagor publish`. Uninstall the old
76
+ `html_to_gutenberg` tool first, otherwise two tools fight over the same command. This is also how an AI agent
77
+ bootstraps this CLI on a fresh machine/sandbox where it isn't installed
78
+ yet — see `src/rb_html_to_gutenberg/data/SKILL.md`.
79
+
80
+ **Update** an installed copy to the latest commit:
81
+
82
+ ```bash
83
+ uv tool upgrade rb-html-to-gutenberg
84
+ ```
85
+
86
+ After install, the command `html_to_gutenberg` is available globally, on
87
+ macOS, Linux and Windows alike (see `architecture.md` in the cli-generator
88
+ plugin for why: no shelling out, no hardcoded POSIX paths).
89
+
90
+ To pick up later template changes, see `existing-package.md` in the `cli-generator` plugin (`copier update`).
91
+
92
+ ## Architecture
93
+
94
+ This project follows a fixed CLI architecture:
95
+
96
+ - `src/rb_html_to_gutenberg/commands/` — argument parsing only, no business logic.
97
+ - `src/rb_html_to_gutenberg/core/` — services, models, errors: the real logic.
98
+ - `src/rb_html_to_gutenberg/providers/` — external APIs/integrations.
99
+ - `src/rb_html_to_gutenberg/credentials/` — secrets via the OS keychain (`keyring`)
100
+ and environment variables. Secrets never live in `.html_to_gutenberg/config.toml`.
101
+ - `src/rb_html_to_gutenberg/output/` — human (`rich`) and `--json` rendering.
102
+
103
+ Run `html_to_gutenberg doctor` to check environment/config/auth readiness, and
104
+ `html_to_gutenberg --help` for the full command surface. Every command supports
105
+ `--json` for machine/agent consumption; errors are structured (`error.code`,
106
+ fixed exit codes, `error.action` telling you what to do next) and go to
107
+ stderr in human mode, so stdout is always safe to pipe.
108
+
109
+ A project can require a minimum CLI version in its `.html_to_gutenberg/config.toml`
110
+ (`[cli] min_version = "..."`); an older install refuses with exit 6 and
111
+ `uv tool upgrade rb-html-to-gutenberg` fixes it.
112
+
113
+ See `src/rb_html_to_gutenberg/data/SKILL.md` for the agent-facing usage guide
114
+ bundled with this package — install it into an AI tool with
115
+ `html_to_gutenberg skill install`, or get it as plain text with
116
+ `html_to_gutenberg --ai` (works even without file access).
@@ -0,0 +1,165 @@
1
+ [project]
2
+ name = "rb-html-to-gutenberg"
3
+ # Version comes from the git tag vX.Y.Z (uv-dynamic-versioning) — never add `version =`.
4
+ dynamic = ["version"]
5
+ description = "Convert HTML into WordPress Gutenberg blocks."
6
+ readme = "README.md"
7
+ license = "MIT"
8
+ license-files = ["LICENSE"]
9
+ authors = [{ name = "bolandeu" }]
10
+ requires-python = ">=3.14"
11
+ dependencies = [
12
+ "typer>=0.27,<0.29",
13
+ "rich>=13.7",
14
+ "pydantic>=2.6",
15
+ "tomli-w>=1.0",
16
+ "platformdirs>=4.2",
17
+ "httpx>=0.27",
18
+ "packaging>=24.0",
19
+ "beautifulsoup4>=4.12",
20
+ ]
21
+
22
+ [project.scripts]
23
+ html_to_gutenberg = "rb_html_to_gutenberg.cli:main"
24
+ html-to-gutenberg = "rb_html_to_gutenberg.cli:main"
25
+
26
+ [project.urls]
27
+ Repository = "https://github.com/bolandeu/html-to-gutenberg"
28
+
29
+ [build-system]
30
+ requires = ["hatchling", "uv-dynamic-versioning"]
31
+ build-backend = "hatchling.build"
32
+
33
+ [tool.hatch.version]
34
+ source = "uv-dynamic-versioning"
35
+
36
+ [tool.uv-dynamic-versioning]
37
+ vcs = "git"
38
+ style = "pep440"
39
+ fallback-version = "0.0.0"
40
+
41
+ [tool.uv]
42
+ # Rebuild the editable install when a commit or tag moves, so `--version` follows the tag.
43
+ cache-keys = [{ file = "pyproject.toml" }, { git = { commit = true, tags = true } }]
44
+
45
+ [tool.hatch.build.targets.sdist]
46
+ # What a release must not carry: the agent's own files, the forge configs and the dev tooling. The wheel is
47
+ # narrow already (`packages = ["src/<pkg>"]`); this is about the sdist, which is otherwise a copy of the repo.
48
+ exclude = [
49
+ "/.agents",
50
+ "/.claude",
51
+ "/.claude-plugin",
52
+ "/.gitea",
53
+ "/.github",
54
+ "/docs",
55
+ "/scripts",
56
+ "/uv.lock",
57
+ "/AGENTS.md",
58
+ "/CLAUDE.md",
59
+ "/CODING_STANDARDS.md",
60
+ "/CONTEXT.md",
61
+ "/.copier-answers.yml",
62
+ "^\\.gitignore$",
63
+ "/.gitleaks.toml",
64
+ ]
65
+
66
+ [tool.hatch.build.targets.wheel]
67
+ packages = ["src/rb_html_to_gutenberg"]
68
+
69
+ [tool.hatch.build.targets.wheel.force-include]
70
+ # The installed CLI reads [[tool.rb.external]] from here (core/deps.py).
71
+ "pyproject.toml" = "html_to_gutenberg/_pyproject.toml"
72
+
73
+ [dependency-groups]
74
+ # Mutation testing, run now and then and before big releases — not in the gate:
75
+ # `uv run --group mutation mutmut run`, then `mutmut results` / `mutmut browse`.
76
+ # Needs fork(): macOS/Linux (WSL on Windows). Settings: [tool.mutmut] below.
77
+ mutation = ["mutmut>=3.3"]
78
+ dev = [
79
+ "jsonschema>=4.23",
80
+ "pytest>=8.0",
81
+ "pyyaml>=6.0", # .copier-answers.yml, the CI workflow, tests/contracts/*.yaml
82
+ "pytest-cov>=5.0",
83
+ "ruff>=0.6",
84
+ "syrupy>=4.8",
85
+ "ty>=0.0.80",
86
+ ]
87
+
88
+ # External (non-Python) dependencies — every CLI this tool runs (require_cli,
89
+ # shutil.which, subprocess with a literal program, npx). The gate checks this
90
+ # list against the code both ways; doctor and require_cli read it at runtime;
91
+ # the tools catalog reads it (the Standard, Technology).
92
+ # [[tool.rb.external]]
93
+ # name = "ffmpeg"
94
+ # required = true # false: the tool works without it (doctor stays healthy)
95
+ # min_version = "6.0" # optional
96
+ # check = "ffmpeg -version" # prints the version; default "<name> --version"
97
+ # why = "transcodes the downloaded videos"
98
+ # detect = false # run via an injected runner / absolute path the gate can't see
99
+ # dist = "rb-serp" # for one of our CLIs: its distribution (default rb-<name>)
100
+ # url = "https://github.com/bolandeu/serp" # its repo: DEPENDENCY_TOO_OLD then prints a pinned install
101
+
102
+ # Where sysadmin's tool-updater installs this tool after its first tag. The
103
+ # installation is sysadmin's; this section only says where. homeserver: users
104
+ # to install for (empty = build and publish only); mac: install on the Mac.
105
+ # extras (optional): the extras to install with, e.g. extras = ["browser"].
106
+ [tool.rb.install]
107
+ homeserver = ["rbtools"]
108
+ mac = true
109
+
110
+ [tool.cli-generator]
111
+ # Where scripts/check_command_docstrings.py (called by the project's checks)
112
+ # looks for commands: a glob or a list of globs, relative to the repo root.
113
+ commands = ["src/rb_html_to_gutenberg/commands/*.py"]
114
+ # gate check (the gate): extras to install before ruff/ty/pytest.
115
+ # gate_extras = ["browser"]
116
+
117
+ [tool.pytest.ini_options]
118
+ # Only tests/: mutmut leaves a copy of the tree in mutants/.
119
+ testpaths = ["tests"]
120
+ addopts = "--cov --cov-report=term-missing:skip-covered"
121
+ # tests/test_help.py keeps help snapshots at tests/snapshots/help/<command>.txt
122
+ # (the Standard, Commands), not in syrupy's own `__snapshots__/<test file>/` layout, so
123
+ # syrupy warns it "can not relate" each file to its test. It can — by name.
124
+ filterwarnings = ["ignore:(?s).*Can not relate snapshot:UserWarning"]
125
+
126
+ [tool.mutmut]
127
+ source_paths = ["src/rb_html_to_gutenberg"]
128
+ also_copy = ["scripts/", "pyproject.toml"] # tests read them (test_scripts.py, the distribution checks)
129
+ pytest_add_cli_args = ["--no-cov"] # fail_under would kill every mutant
130
+ # only_mutate = ["*/core/normalize.py"] # one module at a time on a big tool
131
+
132
+ [tool.coverage.run]
133
+ source = ["src"]
134
+ # sysmon (default on 3.14) keeps a record per recompiled code object; Typer recompiles annotations on every invoke, so memory grows.
135
+ core = "ctrace"
136
+
137
+ [tool.coverage.report]
138
+ # The template ships at ~94%; keep the bar where it is instead of letting
139
+ # new commands land untested. Raise it, never lower it.
140
+ fail_under = 90
141
+ show_missing = true
142
+
143
+ [tool.ty.terminal]
144
+ # Only errors fail the gate; recent ty (>= 0.0.84) otherwise exits 1 on warnings too.
145
+ # Legacy code that can't be fixed yet: downgrade specific rules instead of
146
+ # ignoring them, e.g. [tool.ty.rules] possibly-unbound-attribute = "warn".
147
+ error-on-warning = false
148
+
149
+ [tool.ruff]
150
+ line-length = 120
151
+
152
+ [tool.ruff.lint]
153
+ select = ["E4", "E7", "E9", "F", "I", "UP", "B", "SIM", "RUF", "S", "T20", "TID251"]
154
+
155
+ [tool.ruff.lint.per-file-ignores]
156
+ "tests/*" = ["S101", "T201", "TID251"] # assert is the point of a test; print in code strings; httpx for mocks
157
+ "scripts/*" = ["S603", "S607", "T201"] # subprocess with fixed argv lists (git, uv), no shell; scripts print to the console
158
+ "src/*/providers/*" = ["TID251"] # external APIs live here
159
+
160
+ [tool.ruff.lint.flake8-tidy-imports.banned-api]
161
+ "httpx".msg = "Call external APIs through providers/ (subclass providers.HttpProvider)."
162
+
163
+ [tool.ruff.lint.flake8-bugbear]
164
+ # Typer's `param: T = typer.Option(...)` style is a call in a default on purpose.
165
+ extend-immutable-calls = ["typer.Option", "typer.Argument"]
@@ -0,0 +1,5 @@
1
+ """html-to-gutenberg — конвертация HTML в WordPress Gutenberg блоки."""
2
+
3
+ from .core.converter import Conversion, HtmlToGutenberg
4
+
5
+ __all__ = ["Conversion", "HtmlToGutenberg"]
@@ -0,0 +1,24 @@
1
+ """The distribution name and the tool namespace copier writes from its answers, because an editable install cannot map
2
+ this import package to its distribution at runtime.
3
+ """
4
+
5
+ # Rendered by copier from the `dist_name` answer: the [project] name in
6
+ # pyproject.toml (`rb-<slug>`, the Standard, Technology), which may differ from this
7
+ # import package's name. importlib.metadata finds this package's version,
8
+ # summary and console script by it; an editable install (`uv sync`) can't be
9
+ # mapped from package to distribution at runtime, so it is written down here.
10
+ # tests/test_cli.py fails if it drifts from pyproject.toml.
11
+ DIST_NAME = "rb-html-to-gutenberg"
12
+ # The previous distribution name during a rename: an install made
13
+ # under it (not yet reinstalled) still finds its own version. Drop it once
14
+ # every machine has the new name.
15
+ DIST_NAME_LEGACY: str | None = "html_to_gutenberg"
16
+ # The command name (`cli_name`) as an identifier: the namespace of this tool's
17
+ # shared-database names (core/db.py) — table prefix `<TOOL>_`, env var
18
+ # `<TOOL>_DATABASE_URL`, Alembic table `alembic_version_<TOOL>`. Written down,
19
+ # not derived at runtime: a bare source run falls back to the package name,
20
+ # and a table name must never depend on how the tool was started.
21
+ TOOL = "html_to_gutenberg"
22
+ # The cli-generator release this project was generated or last updated from
23
+ # (copier's `_commit`), for `describe --json`; None for a project not made by copier.
24
+ TEMPLATE_VERSION: str | None = "v1.27.3"
@@ -0,0 +1,69 @@
1
+ """The root Typer app: global options, the command groups and the optional commands a generated package has, wired
2
+ together, and the console-script entry point.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import typer
8
+
9
+ from . import output
10
+ from .commands import auth, convert, doctor
11
+ from .core.version import DEV_VERSION, cli_name, installed_version, optional_module, package_summary
12
+
13
+ _PACKAGE_NAME = __name__.split(".")[0]
14
+ # Optional parts (copier questions, dropped by _exclude): each one ships a module that registers its
15
+ # commands and global options. Probed at runtime, so this file needs no template logic.
16
+ PARTS = ("project", "skill", "describe", "db")
17
+
18
+ # A bare `<cli>` is the discovery entry point for humans and agents alike:
19
+ # name + version + description, then every command with the first line of
20
+ # its docstring. No `no_args_is_help` (that exits 2) — main_options() below
21
+ # prints this and exits 0. Shell completion stays enabled.
22
+ app = typer.Typer(
23
+ cls=output.RootGroup, # a usage error under --json is the error envelope
24
+ help=f"{cli_name()} {installed_version() or DEV_VERSION} — {package_summary() or 'project-aware automation CLI'}",
25
+ )
26
+
27
+ app.add_typer(auth.app, name="auth") # `auth status` in every CLI; login/logout only with credentials
28
+ app.command(name="doctor")(doctor.doctor)
29
+ app.command(name="convert")(convert.convert)
30
+ for part in PARTS:
31
+ if module := optional_module(f"{_PACKAGE_NAME}.commands.{part}"):
32
+ module.register(app)
33
+
34
+
35
+ def _version_callback(value: bool) -> None:
36
+ if not value:
37
+ return
38
+ typer.echo(installed_version() or DEV_VERSION)
39
+ raise typer.Exit()
40
+
41
+
42
+ @app.callback(invoke_without_command=True)
43
+ def main_options(
44
+ ctx: typer.Context,
45
+ json_output: bool = typer.Option(False, "--json", help="Emit machine-readable JSON output."),
46
+ quiet: bool = typer.Option(False, "--quiet", help="Suppress non-essential output."),
47
+ verbose: bool = typer.Option(False, "--verbose", help="Emit extra diagnostic output."),
48
+ non_interactive: bool = typer.Option(False, "--non-interactive", help="Never prompt; fail instead."),
49
+ dry_run: bool = typer.Option(False, "--dry-run", help="Show what would happen without making changes."),
50
+ version: bool = typer.Option(
51
+ False, "--version", callback=_version_callback, is_eager=True, help="Show the version and exit."
52
+ ),
53
+ ) -> None:
54
+ ctx.ensure_object(dict) # a part's global option (--project) may have put its value here already
55
+ ctx.obj["json"] = json_output
56
+ ctx.obj["quiet"] = quiet
57
+ ctx.obj["verbose"] = verbose
58
+ ctx.obj["non_interactive"] = non_interactive
59
+ ctx.obj["dry_run"] = dry_run
60
+ output.configure_logging(verbose)
61
+ output.help_if_no_command(ctx)
62
+
63
+
64
+ def main() -> None:
65
+ app()
66
+
67
+
68
+ if __name__ == "__main__":
69
+ main()
@@ -0,0 +1 @@
1
+ """The commands of the CLI, one module per command or command group."""
@@ -0,0 +1,66 @@
1
+ """The `auth` command group: `status` reports the health of the credentials of every provider, or an empty report when
2
+ the package has none.
3
+ """
4
+
5
+ from __future__ import annotations
6
+
7
+ import importlib
8
+ from datetime import UTC, datetime
9
+
10
+ import typer
11
+
12
+ from .. import output
13
+ from ..core.errors import InvalidArguments
14
+ from ..core.version import DEV_VERSION, cli_name, installed_version, module_exists, optional_module
15
+
16
+ # `auth status` exists in every CLI (the Standard, Health); a CLI
17
+ # generated without credentials (no credentials/ package, no commands/login.py)
18
+ # reports an empty `credentials` list and exits 0. Detected at runtime so this
19
+ # file needs no template logic — same approach as doctor.py.
20
+ _PACKAGE_NAME = __name__.split(".")[0]
21
+ _HAS_CREDENTIALS = module_exists(f"{_PACKAGE_NAME}.credentials.manager")
22
+
23
+ app = output.group("Credentials: report their health (and store them, if this CLI has any).")
24
+
25
+
26
+ @app.command("status")
27
+ @output.guard
28
+ def auth_status(
29
+ ctx: typer.Context,
30
+ check: bool = typer.Option(
31
+ False, "--check", help="Also make one cheap read-only call per provider (10 s timeout) to prove each works."
32
+ ),
33
+ provider: str | None = typer.Option(
34
+ None, "--provider", help="Report only this provider, or one target as <kind>:<target> (default: all)."
35
+ ),
36
+ json_output: bool = output.JsonOption,
37
+ quiet: bool = output.QuietOption,
38
+ ) -> None:
39
+ """Report every provider's credential: where it comes from and whether it works. Never prints values.
40
+
41
+ Without --check only presence is reported (status `unchecked` or `missing`).
42
+ Exits 0 when every required provider is ok/unchecked (an optional one may be
43
+ missing), 3 when any required provider has a problem or any credential is
44
+ invalid/expired, 2 on a usage error. A per-target provider (one credential per
45
+ site/host/account) gets one entry per stored target, named `<kind>:<target>`. The --json shape is a cross-tool contract:
46
+ `tool`, `version`, `checked_at`, `credentials[]` with `provider`, `required`,
47
+ `fields`, `source`, `source_ref`, `status`, `expires_at`, `quota`, `message`.
48
+
49
+ Example: {cli} auth status --check --json
50
+ """
51
+ tool, version = cli_name(), installed_version() or DEV_VERSION
52
+ if not _HAS_CREDENTIALS:
53
+ if provider is not None:
54
+ raise InvalidArguments(f"Unknown provider '{provider}' ({tool} stores no credentials).")
55
+ checked_at = datetime.now(UTC).replace(microsecond=0).isoformat().replace("+00:00", "Z")
56
+ payload = {"tool": tool, "version": version, "checked_at": checked_at, "credentials": []}
57
+ output.emit_report(ctx, payload, lambda _: output.human.echo(f"{tool} stores no credentials."), None)
58
+ return
59
+ health = importlib.import_module(f"{_PACKAGE_NAME}.credentials.health")
60
+ payload, problem = health.status(tool, version, check=check, only=provider)
61
+ output.emit_report(ctx, payload, health.render, problem)
62
+
63
+
64
+ if _login := optional_module(f"{_PACKAGE_NAME}.commands.login"):
65
+ app.command("login")(_login.login)
66
+ app.command("logout")(_login.logout)