svc-infra 0.1.617__py3-none-any.whl → 0.1.618__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.

Potentially problematic release.


This version of svc-infra might be problematic. Click here for more details.

@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ from importlib.metadata import PackageNotFoundError, distribution
4
5
  from pathlib import Path
5
6
  from typing import Dict, List
6
7
 
@@ -20,9 +21,35 @@ def _discover_fs_topics(docs_dir: Path) -> Dict[str, Path]:
20
21
  return topics
21
22
 
22
23
 
23
- def _discover_pkg_topics() -> Dict[str, object]:
24
- # No bundled fallback; docs are packaged from repo root 'docs/'
25
- return {}
24
+ def _discover_pkg_topics() -> Dict[str, Path]:
25
+ """Discover docs packaged under 'docs/' in the installed distribution.
26
+
27
+ This lets 'svc-infra docs' work from external projects that don't have a
28
+ local docs/ directory by falling back to files shipped in the wheel.
29
+ """
30
+ topics: Dict[str, Path] = {}
31
+ try:
32
+ dist = distribution("svc-infra")
33
+ except PackageNotFoundError:
34
+ return topics
35
+
36
+ files = getattr(dist, "files", None) or []
37
+ for f in files:
38
+ # f is a PackagePath; string form like 'docs/topic.md'
39
+ s = str(f)
40
+ if not s.startswith("docs/") or not s.endswith(".md"):
41
+ continue
42
+ name = Path(s).stem.replace(" ", "-")
43
+ try:
44
+ abs_path = dist.locate_file(f)
45
+ # Ensure it's a file before adding
46
+ abs_p = Path(abs_path)
47
+ if abs_p.exists() and abs_p.is_file():
48
+ topics[name] = abs_p
49
+ except Exception:
50
+ # best-effort; skip unreadable entries
51
+ continue
52
+ return topics
26
53
 
27
54
 
28
55
  def _resolve_docs_dir(ctx: click.Context) -> Path | None:
@@ -56,7 +83,10 @@ class DocsGroup(TyperGroup):
56
83
  names: List[str] = list(super().list_commands(ctx) or [])
57
84
  dir_to_use = _resolve_docs_dir(ctx)
58
85
  fs = _discover_fs_topics(dir_to_use) if dir_to_use else {}
59
- names.extend(fs.keys())
86
+ pkg = _discover_pkg_topics()
87
+ # FS topics win on conflicts; add both for visibility
88
+ names.extend([k for k in fs.keys()])
89
+ names.extend([k for k in pkg.keys() if k not in fs])
60
90
  # Deduplicate and sort
61
91
  uniq = sorted({*names})
62
92
  return uniq
@@ -79,7 +109,16 @@ class DocsGroup(TyperGroup):
79
109
 
80
110
  return _show_fs
81
111
 
82
- # No packaged fallback
112
+ # Packaged fallback
113
+ pkg = _discover_pkg_topics()
114
+ if name in pkg:
115
+ file_path = pkg[name]
116
+
117
+ @click.command(name=name)
118
+ def _show_pkg() -> None:
119
+ click.echo(file_path.read_text(encoding="utf-8", errors="replace"))
120
+
121
+ return _show_pkg
83
122
 
84
123
  return None
85
124
 
@@ -114,13 +153,23 @@ def register(app: typer.Typer) -> None:
114
153
  root = resolve_project_root()
115
154
  dir_to_use = _resolve_docs_dir(ctx)
116
155
  fs = _discover_fs_topics(dir_to_use) if dir_to_use else {}
117
- for name, path in fs.items():
156
+ pkg = _discover_pkg_topics()
157
+
158
+ # Print FS topics first (project/env/option), then packaged topics not shadowed by FS
159
+ def _print(name: str, path: Path) -> None:
118
160
  try:
119
161
  rel = path.relative_to(root)
120
162
  typer.echo(f"{name}\t{rel}")
121
163
  except Exception:
164
+ # For packaged topics, path will be site-packages absolute path
122
165
  typer.echo(f"{name}\t{path}")
123
166
 
167
+ for name, path in fs.items():
168
+ _print(name, path)
169
+ for name, path in pkg.items():
170
+ if name not in fs:
171
+ _print(name, path)
172
+
124
173
  # Also support a generic "show" command
125
174
  @docs_app.command("show", help="Show docs for a topic (alternative to dynamic subcommand)")
126
175
  def show(topic: str) -> None:
@@ -130,6 +179,10 @@ def register(app: typer.Typer) -> None:
130
179
  if topic in fs:
131
180
  typer.echo(fs[topic].read_text(encoding="utf-8", errors="replace"))
132
181
  return
182
+ pkg = _discover_pkg_topics()
183
+ if topic in pkg:
184
+ typer.echo(pkg[topic].read_text(encoding="utf-8", errors="replace"))
185
+ return
133
186
  raise typer.BadParameter(f"Unknown topic: {topic}")
134
187
 
135
188
  app.add_typer(docs_app, name="docs")
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: svc-infra
3
- Version: 0.1.617
3
+ Version: 0.1.618
4
4
  Summary: Infrastructure for building and deploying prod-ready services
5
5
  License: MIT
6
6
  Keywords: fastapi,sqlalchemy,alembic,auth,infra,async,pydantic
@@ -142,7 +142,7 @@ svc_infra/cli/cmds/db/sql/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
142
142
  svc_infra/cli/cmds/db/sql/alembic_cmds.py,sha256=kkAu8sfBLWbb9ApMS95b7b_c6GifqvPaRsO7K8icMVI,9649
143
143
  svc_infra/cli/cmds/db/sql/sql_export_cmds.py,sha256=6MxoQO-9upoXg0cl1RHIqz96yXFVGidiBYp_ewhB0E0,2700
144
144
  svc_infra/cli/cmds/db/sql/sql_scaffold_cmds.py,sha256=eNTCqHXOxgl9H3WTbGVn9BHXYwCpjIEJsDqhEFdrYMM,4613
145
- svc_infra/cli/cmds/docs/docs_cmds.py,sha256=A3LT__UffM8elPGTnaXmjNqsq8h4y2VVMMSzoqAeZeM,4668
145
+ svc_infra/cli/cmds/docs/docs_cmds.py,sha256=nvqxkqeYNSV79Eeq0Kv8PN1M8CbyS3lnrFNjHNlO53w,6661
146
146
  svc_infra/cli/cmds/dx/__init__.py,sha256=wQtl3-kOgoESlpVkjl3YFtqkOnQSIvVsOdutiaZFejM,197
147
147
  svc_infra/cli/cmds/dx/dx_cmds.py,sha256=XTKUJzS3UIYn6h3CHzDEWKYJaWn0TzGiUCq3OeW27E0,3326
148
148
  svc_infra/cli/cmds/help.py,sha256=wGfZFMYaR2ZPwW2JwKDU7M3m4AtdCd8GRQ412AmEBUM,758
@@ -296,7 +296,7 @@ svc_infra/webhooks/fastapi.py,sha256=BCNvGNxukf6dC2a4i-6en-PrjBGV19YvCWOot5lXWsA
296
296
  svc_infra/webhooks/router.py,sha256=6JvAVPMEth_xxHX-IsIOcyMgHX7g1H0OVxVXKLuMp9w,1596
297
297
  svc_infra/webhooks/service.py,sha256=hWgiJRXKBwKunJOx91C7EcLUkotDtD3Xp0RT6vj2IC0,1797
298
298
  svc_infra/webhooks/signing.py,sha256=NCwdZzmravUe7HVIK_uXK0qqf12FG-_MVsgPvOw6lsM,784
299
- svc_infra-0.1.617.dist-info/METADATA,sha256=gFtkUXgTuAGcECWRsaWvXwoxnTEqxyl2yTYw9zzYhSk,8106
300
- svc_infra-0.1.617.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
301
- svc_infra-0.1.617.dist-info/entry_points.txt,sha256=6x_nZOsjvn6hRZsMgZLgTasaCSKCgAjsGhACe_CiP0U,48
302
- svc_infra-0.1.617.dist-info/RECORD,,
299
+ svc_infra-0.1.618.dist-info/METADATA,sha256=mH41WGLu0texy6G1rqK_cX5DmiJZFrhIN6kn6GgvLfE,8106
300
+ svc_infra-0.1.618.dist-info/WHEEL,sha256=IYZQI976HJqqOpQU6PHkJ8fb3tMNBFjg-Cn-pwAbaFM,88
301
+ svc_infra-0.1.618.dist-info/entry_points.txt,sha256=6x_nZOsjvn6hRZsMgZLgTasaCSKCgAjsGhACe_CiP0U,48
302
+ svc_infra-0.1.618.dist-info/RECORD,,