mcdview 0.26.2__tar.gz → 0.27.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcdview
3
- Version: 0.26.2
3
+ Version: 0.27.0
4
4
  Summary: Turn a SQL data model into one self-contained, interactive HTML page
5
5
  Project-URL: Homepage, https://github.com/Gheop/mcdview
6
6
  Project-URL: Demo, https://gheop.github.io/mcdview/
@@ -323,6 +323,13 @@ file's header.
323
323
 
324
324
  ## Changelog
325
325
 
326
+ ### v0.27.0 — `--to-dico` data dictionary on the CLI (2026-08-30)
327
+
328
+ - `--to-dico` outputs a Markdown data dictionary (one `## schema.table` section
329
+ with a `column / type / key` table) instead of the HTML page — to `-o` if
330
+ given, else stdout. Same content as the in-page **export → Markdown**, now
331
+ scriptable for a docs/CI pipeline like `--to-mermaid` and `--to-preview`.
332
+
326
333
  ### v0.26.2 — Auto-dismiss the hint banner (2026-08-30)
327
334
 
328
335
  - The transient hint banner (e.g. "No probable missing FK", "No match", a
@@ -301,6 +301,13 @@ file's header.
301
301
 
302
302
  ## Changelog
303
303
 
304
+ ### v0.27.0 — `--to-dico` data dictionary on the CLI (2026-08-30)
305
+
306
+ - `--to-dico` outputs a Markdown data dictionary (one `## schema.table` section
307
+ with a `column / type / key` table) instead of the HTML page — to `-o` if
308
+ given, else stdout. Same content as the in-page **export → Markdown**, now
309
+ scriptable for a docs/CI pipeline like `--to-mermaid` and `--to-preview`.
310
+
304
311
  ### v0.26.2 — Auto-dismiss the hint banner (2026-08-30)
305
312
 
306
313
  - The transient hint banner (e.g. "No probable missing FK", "No match", a
@@ -1606,6 +1606,36 @@ def vers_mermaid(tables, fks):
1606
1606
  return '\n'.join(lignes) + '\n'
1607
1607
 
1608
1608
 
1609
+ def vers_dico(tables, fks, titre):
1610
+ """A Markdown data dictionary: one section per table with a
1611
+ column / type / key row. Pastes into a wiki or a .md (GitHub/GitLab render
1612
+ the tables). Same shape as the in-page "export → Markdown"."""
1613
+ def cell(s):
1614
+ return str(s).replace('|', '\\|')
1615
+ fk_par = {}
1616
+ for f in fks:
1617
+ fk_par.setdefault(f['de'], {})[f['col']] = f['vers']
1618
+ lignes = ['# ' + titre, '']
1619
+ for cle in sorted(tables):
1620
+ t = tables[cle]
1621
+ fk = fk_par.get(cle, {})
1622
+ lignes += ['## ' + cle, '']
1623
+ if t.get('comment'):
1624
+ lignes += ['> ' + t['comment'].replace('\n', ' '), '']
1625
+ lignes += ['| column | type | key |', '| --- | --- | --- |']
1626
+ for c in t['cols']:
1627
+ if c['nom'] in t['pk']:
1628
+ k = 'PK'
1629
+ elif c['nom'] in fk:
1630
+ k = 'FK → ' + fk[c['nom']].split('.', 1)[-1]
1631
+ else:
1632
+ k = ''
1633
+ typ = c['type'] + (' NOT NULL' if c['nn'] else '')
1634
+ lignes.append(f"| {cell(c['nom'])} | {cell(typ)} | {cell(k)} |")
1635
+ lignes.append('')
1636
+ return '\n'.join(lignes)
1637
+
1638
+
1609
1639
  def vers_svg(tables, fks, couleurs):
1610
1640
  """A static SVG snapshot of the diagram, for social/OpenGraph cards: the
1611
1641
  auto-layout positions, the same box sizing as the interactive page, table
@@ -1678,6 +1708,10 @@ def principal():
1678
1708
  ap.add_argument('--to-preview', action='store_true',
1679
1709
  help='output a static SVG snapshot of the diagram (for a social '
1680
1710
  'card / OpenGraph image) instead of the HTML page')
1711
+ ap.add_argument('--to-dico', action='store_true',
1712
+ help='output a Markdown data dictionary (one section per table, '
1713
+ 'column/type/key) instead of the HTML page; to -o if given, '
1714
+ 'else stdout')
1681
1715
  ap.add_argument('--lint', action='store_true',
1682
1716
  help='check the schema against a set of rules (missing PK, '
1683
1717
  'unindexed FK, naming…) and print JSON violations instead '
@@ -1720,7 +1754,7 @@ def principal():
1720
1754
 
1721
1755
  generer(args, ap)
1722
1756
  if args.watch:
1723
- if args.db or args.to_mermaid or args.to_preview or not args.sql:
1757
+ if args.db or args.to_mermaid or args.to_preview or args.to_dico or not args.sql:
1724
1758
  ap.error('--watch needs a model file (not --db or --to-mermaid)')
1725
1759
  surveiller(args, ap)
1726
1760
 
@@ -1922,6 +1956,15 @@ def generer(args, ap):
1922
1956
  sys.stdout.write(mmd)
1923
1957
  return
1924
1958
 
1959
+ if args.to_dico:
1960
+ md = vers_dico(tables, fks, args.titre or nom_defaut)
1961
+ if args.sortie:
1962
+ Path(args.sortie).write_text(md)
1963
+ print(f'{len(tables)} tables, {len(fks)} FKs → {args.sortie} (data dictionary)')
1964
+ else:
1965
+ sys.stdout.write(md)
1966
+ return
1967
+
1925
1968
  if args.diff:
1926
1969
  vieux = charger(args.diff, args.dialect)[:2]
1927
1970
  tables, fks = comparer(vieux, (tables, fks))
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "mcdview"
7
- version = "0.26.2"
7
+ version = "0.27.0"
8
8
  description = "Turn a SQL data model into one self-contained, interactive HTML page"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.9"
File without changes
File without changes
File without changes