@plures/praxis 1.1.3 → 1.2.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.
@@ -605,6 +605,15 @@ program.command("generate").description("Generate code from schemas").option("-s
605
605
  ).action(async (options) => {
606
606
  await generate(options);
607
607
  });
608
+ program.command("docs [schema]").description("Generate documentation from schemas or registries").option("-o, --output <dir>", "Output directory", "./docs").option("--title <title>", "Documentation title").option("--format <format>", "Diagram format (mermaid, dot)", "mermaid").option("--no-toc", "Disable table of contents").option("--no-timestamp", "Disable timestamp").option("--from-registry", "Generate from registry instead of schema").option("--header <content>", "Custom header content").option("--footer <content>", "Custom footer content").action(async (schema, options) => {
609
+ try {
610
+ const { docs } = await import("../docs-JFNYTOJA.js");
611
+ await docs(schema, options);
612
+ } catch (error) {
613
+ console.error("Error generating documentation:", error);
614
+ process.exit(1);
615
+ }
616
+ });
608
617
  program.command("canvas [schema]").description("Open CodeCanvas for visual editing").option("-p, --port <port>", "Port for Canvas server", "3000").option("-m, --mode <mode>", "Mode (edit, view, present)", "edit").option("-e, --export <format>", "Export format (yaml, mermaid, json)").option("-o, --output <file>", "Output file for export").action(async (schema, options) => {
609
618
  try {
610
619
  const { canvas } = await import("../canvas-UERZHJYW.js");
@@ -0,0 +1,102 @@
1
+ import {
2
+ createStateDocsGenerator
3
+ } from "./chunk-S54337I5.js";
4
+ import {
5
+ loadSchemaFromFile
6
+ } from "./chunk-UY7YEBE2.js";
7
+ import "./chunk-UATVJBNV.js";
8
+ import "./chunk-QGM4M3NI.js";
9
+
10
+ // src/cli/commands/docs.ts
11
+ import * as fs from "fs";
12
+ import * as path from "path";
13
+ async function docs(schemaOrRegistryPath, options) {
14
+ console.log("\n\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557");
15
+ console.log("\u2551 Praxis Documentation Generator \u2551");
16
+ console.log("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D\n");
17
+ if (!schemaOrRegistryPath || !fs.existsSync(schemaOrRegistryPath)) {
18
+ console.error("Error: Schema or registry file required");
19
+ console.log("Usage: praxis docs <schema-file> [options]");
20
+ console.log("\nOptions:");
21
+ console.log(" --output <dir> Output directory (default: ./docs)");
22
+ console.log(" --title <title> Documentation title");
23
+ console.log(" --format <format> Diagram format: mermaid (default) or dot");
24
+ console.log(" --no-toc Disable table of contents");
25
+ console.log(" --no-timestamp Disable timestamp");
26
+ console.log(" --from-registry Generate from registry instead of schema");
27
+ process.exit(1);
28
+ }
29
+ const outputDir = options.output || "./docs";
30
+ const title = options.title || "Praxis Application";
31
+ const generator = createStateDocsGenerator({
32
+ projectTitle: title,
33
+ target: outputDir,
34
+ visualization: {
35
+ format: options.format || "mermaid",
36
+ exportPng: false
37
+ },
38
+ template: {
39
+ toc: options.toc !== false,
40
+ timestamp: options.timestamp !== false,
41
+ header: options.header,
42
+ footer: options.footer
43
+ }
44
+ });
45
+ console.log(`Source: ${schemaOrRegistryPath}`);
46
+ console.log(`Output: ${outputDir}
47
+ `);
48
+ try {
49
+ let generatedDocs;
50
+ if (options.fromRegistry) {
51
+ console.log("Loading registry module...");
52
+ const module = await import(path.resolve(schemaOrRegistryPath));
53
+ const registry = module.registry || module.default || module;
54
+ if (!registry || typeof registry.getAllRules !== "function") {
55
+ console.error("Error: Invalid registry module");
56
+ console.log("Expected: export const registry = new PraxisRegistry()");
57
+ process.exit(1);
58
+ }
59
+ console.log("Generating documentation from registry...");
60
+ const praxisModule = {
61
+ rules: registry.getAllRules(),
62
+ constraints: registry.getAllConstraints()
63
+ };
64
+ generatedDocs = generator.generateFromModule(praxisModule);
65
+ } else {
66
+ console.log("Loading schema...");
67
+ const result = await loadSchemaFromFile(schemaOrRegistryPath);
68
+ if (result.errors.length > 0 || !result.schema) {
69
+ console.error(`Error loading schema: ${result.errors.join(", ")}`);
70
+ process.exit(1);
71
+ }
72
+ console.log("Generating documentation from schema...");
73
+ generatedDocs = generator.generateFromSchema(result.schema);
74
+ }
75
+ if (!fs.existsSync(outputDir)) {
76
+ fs.mkdirSync(outputDir, { recursive: true });
77
+ }
78
+ console.log("\nWriting documentation files:\n");
79
+ for (const doc of generatedDocs) {
80
+ const fullPath = path.resolve(doc.path);
81
+ const dir = path.dirname(fullPath);
82
+ if (!fs.existsSync(dir)) {
83
+ fs.mkdirSync(dir, { recursive: true });
84
+ }
85
+ fs.writeFileSync(fullPath, doc.content);
86
+ console.log(` \u2713 ${doc.path} (${doc.type})`);
87
+ }
88
+ console.log(`
89
+ \u2713 Generated ${generatedDocs.length} documentation file(s)`);
90
+ console.log(`
91
+ View your documentation: ${path.resolve(outputDir, "README.md")}`);
92
+ } catch (error) {
93
+ console.error(`Error generating documentation: ${error}`);
94
+ if (error instanceof Error) {
95
+ console.error(error.stack);
96
+ }
97
+ process.exit(1);
98
+ }
99
+ }
100
+ export {
101
+ docs
102
+ };
@@ -0,0 +1,9 @@
1
+ import {
2
+ LogicEngine,
3
+ createPraxisEngine
4
+ } from "./chunk-VOMLVI6V.js";
5
+ import "./chunk-QGM4M3NI.js";
6
+ export {
7
+ LogicEngine,
8
+ createPraxisEngine
9
+ };