@amritk/mjst 0.23.0 → 0.24.0

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.
package/README.md CHANGED
@@ -321,6 +321,7 @@ npx mjst markdown ./config.schema.json --table --readme ./README.md
321
321
  | `--layout` | Default layout for nested properties: `headings` (default), `table`, or `none`. |
322
322
  | `--sort` | Property order: `schema` (default) or `alphabetical`. |
323
323
  | `--heading-level` | Heading level of the page title, 1-6 (default: `1`). |
324
+ | `--type-label` | Whether every property heading gets its **Type:** line: `auto` (default) or `never`. Under `never` an enum lists its **Allowed values:** instead, since the label was the only other place they appeared. |
324
325
  | `--type-column` | When a property table renders its **Type** column: `auto` (default — only when a row fills it with something a reader could act on), `always`, or `never`. |
325
326
  | `--default-column` | When a property table renders its **Default** column: `auto` (default), `always`, or `never`. |
326
327
  | `--required-style` | How a property table says which properties are required: `marker` (default — `_required_` beside the name) or `column` (a **Required** column). |
@@ -3,4 +3,4 @@
3
3
  * HELP_TEXT: the flag list is small and stable, and the test cross-checks that
4
4
  * every flag is listed.
5
5
  */
6
- export declare const MARKDOWN_HELP_TEXT = "mjst markdown \u2014 generate markdown documentation from a JSON Schema\n\nUsage:\n mjst markdown <schema> --out-dir <dir> [options]\n mjst markdown <schema> --table --readme <file>\n\nTwo shapes come out of the same schema. By default it writes the prose\nreference \u2014 a heading, a type, the description and an example per property,\nacross as many pages as the schema's x-doc keyword declares. With --table it\nrenders one HTML table instead and splices it into an existing markdown file\nbetween <!-- config-table-start --> and <!-- config-table-end -->, leaving the\nrest of that file alone.\n\nProse reference options:\n --out-dir <dir> Directory the pages are written to (default: the current directory)\n --file <path> Output path of the index page (default: the schema's x-doc.file, then index.md)\n --title <text> Page title (default: the schema's title)\n --language <lang> Fence language for derived examples and literals (default: json)\n --layout <mode> Default layout for nested properties: headings (default), table, or none\n --sort <order> Property order: schema (default) or alphabetical\n --heading-level <n> Heading level of the page title, 1-6 (default: 1)\n\nProperty table options (the root x-doc.table, for every table on every page):\n --type-column <when> Render the Type column: auto (default), always, or never\n --default-column <when> Render the Default column: auto (default), always, or never\n --required-style <how> Say which properties are required: marker (default, beside\n the name) or column (a Required column)\n --required-first List the required properties at the top of every table\n\nTable options:\n --table Render the HTML config table instead of the prose pages\n --readme <path> Markdown file the table is spliced into (default: README.md)\n\nMisc:\n --help, -h Print this help\n\nDocs: https://github.com/amritk/mjst/tree/main/packages/cli#readme\n";
6
+ export declare const MARKDOWN_HELP_TEXT = "mjst markdown \u2014 generate markdown documentation from a JSON Schema\n\nUsage:\n mjst markdown <schema> --out-dir <dir> [options]\n mjst markdown <schema> --table --readme <file>\n\nTwo shapes come out of the same schema. By default it writes the prose\nreference \u2014 a heading, a type, the description and an example per property,\nacross as many pages as the schema's x-doc keyword declares. With --table it\nrenders one HTML table instead and splices it into an existing markdown file\nbetween <!-- config-table-start --> and <!-- config-table-end -->, leaving the\nrest of that file alone.\n\nProse reference options:\n --out-dir <dir> Directory the pages are written to (default: the current directory)\n --file <path> Output path of the index page (default: the schema's x-doc.file, then index.md)\n --title <text> Page title (default: the schema's title)\n --language <lang> Fence language for derived examples and literals (default: json)\n --layout <mode> Default layout for nested properties: headings (default), table, or none\n --sort <order> Property order: schema (default) or alphabetical\n --heading-level <n> Heading level of the page title, 1-6 (default: 1)\n --type-label <when> Give every property heading its Type: line: auto (default) or\n never (an enum then lists its allowed values instead)\n\nProperty table options (the root x-doc.table, for every table on every page):\n --type-column <when> Render the Type column: auto (default), always, or never\n --default-column <when> Render the Default column: auto (default), always, or never\n --required-style <how> Say which properties are required: marker (default, beside\n the name) or column (a Required column)\n --required-first List the required properties at the top of every table\n\nTable options:\n --table Render the HTML config table instead of the prose pages\n --readme <path> Markdown file the table is spliced into (default: README.md)\n\nMisc:\n --help, -h Print this help\n\nDocs: https://github.com/amritk/mjst/tree/main/packages/cli#readme\n";
@@ -19,6 +19,8 @@ Prose reference options:
19
19
  --layout <mode> Default layout for nested properties: headings (default), table, or none
20
20
  --sort <order> Property order: schema (default) or alphabetical
21
21
  --heading-level <n> Heading level of the page title, 1-6 (default: 1)
22
+ --type-label <when> Give every property heading its Type: line: auto (default) or
23
+ never (an enum then lists its allowed values instead)
22
24
 
23
25
  Property table options (the root x-doc.table, for every table on every page):
24
26
  --type-column <when> Render the Type column: auto (default), always, or never
@@ -1,4 +1,4 @@
1
- import type { DocLayout, DocSort, DocTableColumn, DocTableRequired } from '@amritk/generate-markdown';
1
+ import type { DocHeadingType, DocLayout, DocSort, DocTableColumn, DocTableRequired } from '@amritk/generate-markdown';
2
2
  /** The flags and positional the `markdown` subcommand understands. */
3
3
  export type MarkdownArgs = {
4
4
  /** Path to the JSON Schema to document (the sole positional). */
@@ -17,6 +17,8 @@ export type MarkdownArgs = {
17
17
  sort?: DocSort;
18
18
  /** Heading level of the page title (`--heading-level`). */
19
19
  headingLevel?: number;
20
+ /** Whether a property heading gets its **Type:** line (`--type-label`). */
21
+ typeLabel?: DocHeadingType;
20
22
  /** When property tables render their Type column (`--type-column`). */
21
23
  typeColumn?: DocTableColumn;
22
24
  /** When property tables render their Default column (`--default-column`). */
@@ -6,6 +6,7 @@ const VALUE_KEYS = /* @__PURE__ */ new Set([
6
6
  "layout",
7
7
  "sort",
8
8
  "headingLevel",
9
+ "typeLabel",
9
10
  "typeColumn",
10
11
  "defaultColumn",
11
12
  "requiredStyle",
@@ -14,6 +15,7 @@ const VALUE_KEYS = /* @__PURE__ */ new Set([
14
15
  const BOOLEAN_KEYS = /* @__PURE__ */ new Set(["table", "requiredFirst"]);
15
16
  const LAYOUTS = ["headings", "table", "none"];
16
17
  const SORTS = ["schema", "alphabetical"];
18
+ const HEADING_TYPES = ["auto", "never"];
17
19
  const TABLE_COLUMNS = ["auto", "always", "never"];
18
20
  const REQUIRED_STYLES = ["marker", "column"];
19
21
  const toCamelCase = (key) => key.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
@@ -54,6 +56,9 @@ const assignValue = (args, key, value) => {
54
56
  case "headingLevel":
55
57
  args.headingLevel = parseHeadingLevel(value);
56
58
  return;
59
+ case "typeLabel":
60
+ args.typeLabel = parseChoice("type-label", value, HEADING_TYPES);
61
+ return;
57
62
  case "typeColumn":
58
63
  args.typeColumn = parseChoice("type-column", value, TABLE_COLUMNS);
59
64
  return;
@@ -14,6 +14,7 @@ const PAGE_FLAGS = [
14
14
  "layout",
15
15
  "sort",
16
16
  "headingLevel",
17
+ "typeLabel",
17
18
  "typeColumn",
18
19
  "defaultColumn",
19
20
  "requiredStyle",
@@ -71,7 +72,8 @@ const run = async (argv) => {
71
72
  default: args.defaultColumn,
72
73
  required: args.requiredStyle,
73
74
  requiredFirst: args.requiredFirst
74
- }
75
+ },
76
+ headings: { type: args.typeLabel }
75
77
  };
76
78
  let files;
77
79
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amritk/mjst",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Generate TypeScript parsers and type definitions from JSON Schemas.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -53,7 +53,7 @@
53
53
  "@amritk/api": "^0.16.5",
54
54
  "@amritk/asyncapi": "^0.3.3",
55
55
  "@amritk/generate-examples": "^0.8.7",
56
- "@amritk/generate-markdown": "^0.9.0",
56
+ "@amritk/generate-markdown": "^0.10.0",
57
57
  "@amritk/helpers": "^0.23.1",
58
58
  "@amritk/lint": "^0.6.1",
59
59
  "@amritk/validation": "^0.3.0",