@pepshlr/pepdoc 0.0.1
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/dist/adapters/express.d.ts +24 -0
- package/dist/adapters/express.d.ts.map +1 -0
- package/dist/adapters/express.js +125 -0
- package/dist/adapters/express.js.map +1 -0
- package/dist/adapters/index.d.ts +2 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/index.js +6 -0
- package/dist/adapters/index.js.map +1 -0
- package/dist/bin/pepsdoc.d.ts +11 -0
- package/dist/bin/pepsdoc.d.ts.map +1 -0
- package/dist/bin/pepsdoc.js +211 -0
- package/dist/bin/pepsdoc.js.map +1 -0
- package/dist/core/config.d.ts +7 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/config.js +29 -0
- package/dist/core/config.js.map +1 -0
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +9 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/schema.d.ts +86 -0
- package/dist/core/schema.d.ts.map +1 -0
- package/dist/core/schema.js +7 -0
- package/dist/core/schema.js.map +1 -0
- package/dist/core/storage.d.ts +28 -0
- package/dist/core/storage.d.ts.map +1 -0
- package/dist/core/storage.js +136 -0
- package/dist/core/storage.js.map +1 -0
- package/dist/export/index.d.ts +2 -0
- package/dist/export/index.d.ts.map +1 -0
- package/dist/export/index.js +7 -0
- package/dist/export/index.js.map +1 -0
- package/dist/export/llm.d.ts +10 -0
- package/dist/export/llm.d.ts.map +1 -0
- package/dist/export/llm.js +79 -0
- package/dist/export/llm.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/package.json +44 -0
- package/templates/ai-skill.md +203 -0
- package/ui/build/assets/index-BmHYXQxb.js +15 -0
- package/ui/build/assets/index-DxKrKvFe.css +2 -0
- package/ui/build/favicon.svg +1 -0
- package/ui/build/icons.svg +24 -0
- package/ui/build/index.html +14 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PepsDoc - Storage
|
|
4
|
+
* Leitura e escrita dos arquivos JSON de documentação
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.Storage = void 0;
|
|
41
|
+
const fs = __importStar(require("fs"));
|
|
42
|
+
const path = __importStar(require("path"));
|
|
43
|
+
const DEFAULT_DIR = 'pepsdoc';
|
|
44
|
+
const CONFIG_FILE = 'pepsdoc.config.json';
|
|
45
|
+
const DATA_DIR = 'data';
|
|
46
|
+
class Storage {
|
|
47
|
+
constructor(projectRoot) {
|
|
48
|
+
this.baseDir = path.join(projectRoot, DEFAULT_DIR);
|
|
49
|
+
}
|
|
50
|
+
/** Caminho da pasta pepsdoc/ */
|
|
51
|
+
get dir() {
|
|
52
|
+
return this.baseDir;
|
|
53
|
+
}
|
|
54
|
+
/** Inicializa a estrutura de pastas */
|
|
55
|
+
init(config) {
|
|
56
|
+
// Cria pepsdoc/
|
|
57
|
+
fs.mkdirSync(this.baseDir, { recursive: true });
|
|
58
|
+
// Cria pepsdoc/data/
|
|
59
|
+
const dataDir = path.join(this.baseDir, DATA_DIR);
|
|
60
|
+
fs.mkdirSync(dataDir, { recursive: true });
|
|
61
|
+
// Cria pepsdoc/pepsdoc.config.json
|
|
62
|
+
const configPath = path.join(this.baseDir, CONFIG_FILE);
|
|
63
|
+
if (!fs.existsSync(configPath)) {
|
|
64
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
65
|
+
}
|
|
66
|
+
// Cria pastas de versão
|
|
67
|
+
const versions = config.versions?.map((v) => v.name) ?? ['v1'];
|
|
68
|
+
for (const version of versions) {
|
|
69
|
+
fs.mkdirSync(path.join(dataDir, version), { recursive: true });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
/** Lê a config */
|
|
73
|
+
readConfig() {
|
|
74
|
+
const configPath = path.join(this.baseDir, CONFIG_FILE);
|
|
75
|
+
if (!fs.existsSync(configPath)) {
|
|
76
|
+
throw new Error(`Config not found: ${configPath}`);
|
|
77
|
+
}
|
|
78
|
+
const raw = fs.readFileSync(configPath, 'utf-8');
|
|
79
|
+
return JSON.parse(raw);
|
|
80
|
+
}
|
|
81
|
+
/** Salva a config */
|
|
82
|
+
writeConfig(config) {
|
|
83
|
+
const configPath = path.join(this.baseDir, CONFIG_FILE);
|
|
84
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2), 'utf-8');
|
|
85
|
+
}
|
|
86
|
+
/** Lê todos os grupos de uma versão */
|
|
87
|
+
readGroups(version) {
|
|
88
|
+
const versionDir = path.join(this.baseDir, DATA_DIR, version);
|
|
89
|
+
if (!fs.existsSync(versionDir))
|
|
90
|
+
return [];
|
|
91
|
+
const files = fs.readdirSync(versionDir).filter((f) => f.endsWith('.json') && f !== 'meta.json');
|
|
92
|
+
const groups = [];
|
|
93
|
+
for (const file of files) {
|
|
94
|
+
const raw = fs.readFileSync(path.join(versionDir, file), 'utf-8');
|
|
95
|
+
groups.push(JSON.parse(raw));
|
|
96
|
+
}
|
|
97
|
+
return groups.sort((a, b) => (a.order ?? 99) - (b.order ?? 99));
|
|
98
|
+
}
|
|
99
|
+
/** Salva um grupo de endpoints */
|
|
100
|
+
writeGroup(version, slug, group) {
|
|
101
|
+
const versionDir = path.join(this.baseDir, DATA_DIR, version);
|
|
102
|
+
fs.mkdirSync(versionDir, { recursive: true });
|
|
103
|
+
const filePath = path.join(versionDir, `${slug}.json`);
|
|
104
|
+
fs.writeFileSync(filePath, JSON.stringify(group, null, 2), 'utf-8');
|
|
105
|
+
}
|
|
106
|
+
/** Lista as versões disponíveis */
|
|
107
|
+
listVersions() {
|
|
108
|
+
const dataDir = path.join(this.baseDir, DATA_DIR);
|
|
109
|
+
if (!fs.existsSync(dataDir))
|
|
110
|
+
return [];
|
|
111
|
+
return fs.readdirSync(dataDir).filter((f) => {
|
|
112
|
+
return fs.statSync(path.join(dataDir, f)).isDirectory();
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
/** Compila tudo num objeto só (pro frontend) */
|
|
116
|
+
compile() {
|
|
117
|
+
const config = this.readConfig();
|
|
118
|
+
const versionNames = this.listVersions();
|
|
119
|
+
const versions = versionNames.map((name) => {
|
|
120
|
+
const vConfig = config.versions?.find((v) => v.name === name);
|
|
121
|
+
return {
|
|
122
|
+
name,
|
|
123
|
+
badge: vConfig?.badge,
|
|
124
|
+
badgeColor: vConfig?.badgeColor,
|
|
125
|
+
groups: this.readGroups(name),
|
|
126
|
+
};
|
|
127
|
+
});
|
|
128
|
+
return { config, versions };
|
|
129
|
+
}
|
|
130
|
+
/** Verifica se o pepsdoc já foi inicializado */
|
|
131
|
+
isInitialized() {
|
|
132
|
+
return fs.existsSync(path.join(this.baseDir, CONFIG_FILE));
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
exports.Storage = Storage;
|
|
136
|
+
//# sourceMappingURL=storage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"storage.js","sourceRoot":"","sources":["../../src/core/storage.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAQ7B,MAAM,WAAW,GAAG,SAAS,CAAC;AAC9B,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAC1C,MAAM,QAAQ,GAAG,MAAM,CAAC;AAExB,MAAa,OAAO;IAGlB,YAAY,WAAmB;QAC7B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,WAAW,CAAC,CAAC;IACrD,CAAC;IAED,gCAAgC;IAChC,IAAI,GAAG;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED,uCAAuC;IACvC,IAAI,CAAC,MAAqB;QACxB,gBAAgB;QAChB,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAEhD,qBAAqB;QACrB,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,CAA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rB,UAAU,EAAE,OAAO,EAAE,UAAU;gBAC/B,MAAM,EAAE,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;aAC9B,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;IAC9B,CAAC;IAED,gDAAgD;IAChD,aAAa;QACX,OAAO,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC,CAAC;IAC7D,CAAC;CACF;AA3GD,0BA2GC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/export/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.dataToLLM = exports.endpointToLLM = void 0;
|
|
4
|
+
var llm_1 = require("./llm");
|
|
5
|
+
Object.defineProperty(exports, "endpointToLLM", { enumerable: true, get: function () { return llm_1.endpointToLLM; } });
|
|
6
|
+
Object.defineProperty(exports, "dataToLLM", { enumerable: true, get: function () { return llm_1.dataToLLM; } });
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/export/index.ts"],"names":[],"mappings":";;;AAAA,6BAAiD;AAAxC,oGAAA,aAAa,OAAA;AAAE,gGAAA,SAAS,OAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PepsDoc - LLM Export
|
|
3
|
+
* Gera markdown otimizado para IA a partir da documentação
|
|
4
|
+
*/
|
|
5
|
+
import type { PepsDocData, Endpoint } from '../core/schema';
|
|
6
|
+
/** Gera markdown de um endpoint específico (botão "Copy for LLM") */
|
|
7
|
+
export declare function endpointToLLM(endpoint: Endpoint, baseUrl?: string): string;
|
|
8
|
+
/** Gera markdown completo de toda a documentação (export para IA de frontend) */
|
|
9
|
+
export declare function dataToLLM(data: PepsDocData, baseUrl?: string): string;
|
|
10
|
+
//# sourceMappingURL=llm.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../src/export/llm.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;AAE3E,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAkD1E;AAED,iFAAiF;AACjF,wBAAgB,SAAS,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CA6BrE"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PepsDoc - LLM Export
|
|
4
|
+
* Gera markdown otimizado para IA a partir da documentação
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.endpointToLLM = endpointToLLM;
|
|
8
|
+
exports.dataToLLM = dataToLLM;
|
|
9
|
+
/** Gera markdown de um endpoint específico (botão "Copy for LLM") */
|
|
10
|
+
function endpointToLLM(endpoint, baseUrl) {
|
|
11
|
+
const url = baseUrl ? `${baseUrl}${endpoint.path}` : endpoint.path;
|
|
12
|
+
let md = `## ${endpoint.method} ${endpoint.path}\n\n`;
|
|
13
|
+
if (endpoint.summary) {
|
|
14
|
+
md += `${endpoint.summary}\n\n`;
|
|
15
|
+
}
|
|
16
|
+
md += `### Request\n`;
|
|
17
|
+
md += `- Method: ${endpoint.method}\n`;
|
|
18
|
+
md += `- URL: ${url}\n`;
|
|
19
|
+
if (endpoint.headers?.length) {
|
|
20
|
+
md += `- Headers:\n`;
|
|
21
|
+
for (const h of endpoint.headers) {
|
|
22
|
+
md += ` - ${h.name}: ${h.type}${h.required ? ' (required)' : ''}\n`;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (endpoint.queryParams?.length) {
|
|
26
|
+
md += `- Query Parameters:\n`;
|
|
27
|
+
for (const p of endpoint.queryParams) {
|
|
28
|
+
md += ` - ${p.name}: ${p.type}${p.required ? ' (required)' : ''}${p.description ? ` — ${p.description}` : ''}\n`;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (endpoint.body) {
|
|
32
|
+
md += `- Content-Type: ${endpoint.body.contentType || 'application/json'}\n`;
|
|
33
|
+
if (endpoint.body.fields?.length) {
|
|
34
|
+
md += `- Body fields:\n`;
|
|
35
|
+
for (const f of endpoint.body.fields) {
|
|
36
|
+
md += ` - ${f.name}: ${f.type}${f.required ? ' (required)' : ''}${f.description ? ` — ${f.description}` : ''}\n`;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (endpoint.body.example) {
|
|
40
|
+
md += `- Body example:\n\`\`\`json\n${JSON.stringify(endpoint.body.example, null, 2)}\n\`\`\`\n`;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
if (endpoint.responses?.length) {
|
|
44
|
+
md += `\n### Responses\n`;
|
|
45
|
+
for (const r of endpoint.responses) {
|
|
46
|
+
md += `\n#### ${r.status}${r.description ? ` — ${r.description}` : ''}\n`;
|
|
47
|
+
if (r.example) {
|
|
48
|
+
md += `\`\`\`json\n${JSON.stringify(r.example, null, 2)}\n\`\`\`\n`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return md;
|
|
53
|
+
}
|
|
54
|
+
/** Gera markdown completo de toda a documentação (export para IA de frontend) */
|
|
55
|
+
function dataToLLM(data, baseUrl) {
|
|
56
|
+
let md = `# ${data.config.title} — API Reference\n\n`;
|
|
57
|
+
if (data.config.description) {
|
|
58
|
+
md += `${data.config.description}\n\n`;
|
|
59
|
+
}
|
|
60
|
+
if (baseUrl) {
|
|
61
|
+
md += `Base URL: \`${baseUrl}\`\n\n`;
|
|
62
|
+
}
|
|
63
|
+
md += `---\n\n`;
|
|
64
|
+
for (const version of data.versions) {
|
|
65
|
+
md += `## Version: ${version.name}`;
|
|
66
|
+
if (version.badge)
|
|
67
|
+
md += ` (${version.badge})`;
|
|
68
|
+
md += `\n\n`;
|
|
69
|
+
for (const group of version.groups) {
|
|
70
|
+
md += `### ${group.group}\n\n`;
|
|
71
|
+
for (const endpoint of group.endpoints) {
|
|
72
|
+
md += endpointToLLM(endpoint, baseUrl);
|
|
73
|
+
md += `\n---\n\n`;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
return md;
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=llm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"llm.js","sourceRoot":"","sources":["../../src/export/llm.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAKH,sCAkDC;AAGD,8BA6BC;AAnFD,qEAAqE;AACrE,SAAgB,aAAa,CAAC,QAAkB,EAAE,OAAgB;IAChE,MAAM,GAAG,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,GAAG,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC;IACnE,IAAI,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,MAAM,CAAC;IAEtD,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,EAAE,IAAI,GAAG,QAAQ,CAAC,OAAO,MAAM,CAAC;IAClC,CAAC;IAED,EAAE,IAAI,eAAe,CAAC;IACtB,EAAE,IAAI,aAAa,QAAQ,CAAC,MAAM,IAAI,CAAC;IACvC,EAAE,IAAI,UAAU,GAAG,IAAI,CAA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C,QAAQ,EAAE,CAAC;QACpC,EAAE,IAAI,eAAe,OAAO,CAAC,IAAI,EAAE,CAAC;QACpC,IAAI,OAAO,CAAC,KAAK;YAAE,EAAE,IAAI,KAAK,OAAO,CAAC,KAAK,GAAG,CAAC;QAC/C,EAAE,IAAI,MAAM,CAAC;QAEb,KAAK,MAAM,KAAK,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnC,EAAE,IAAI,OAAO,KAAK,CAAC,KAAK,MAAM,CAAC;YAE/B,KAAK,MAAM,QAAQ,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;gBACvC,EAAE,IAAI,aAAa,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;gBACvC,EAAE,IAAI,WAAW,CAAC;YACpB,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,CAAC;AACZ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PepsDoc - API documentation, beautifully automated.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* ```ts
|
|
6
|
+
* import express from 'express';
|
|
7
|
+
* import { pepsdoc } from 'pepsdoc';
|
|
8
|
+
*
|
|
9
|
+
* const app = express();
|
|
10
|
+
* pepsdoc(app, { title: 'My API' });
|
|
11
|
+
* app.listen(3000);
|
|
12
|
+
* // Docs at http://localhost:3000/docs
|
|
13
|
+
* ```
|
|
14
|
+
*/
|
|
15
|
+
import type { PepsDocConfig } from './core/schema';
|
|
16
|
+
export declare function pepsdoc(app: unknown, config?: Partial<PepsDocConfig>): void;
|
|
17
|
+
export { expressAdapter } from './adapters/express';
|
|
18
|
+
export { Storage } from './core/storage';
|
|
19
|
+
export { DEFAULT_CONFIG, METHOD_COLORS } from './core/config';
|
|
20
|
+
export { endpointToLLM, dataToLLM } from './export/llm';
|
|
21
|
+
export type { PepsDocConfig, VersionConfig, TabConfig, ThemeConfig, HttpMethod, EndpointGroup, Endpoint, ParamField, RequestBody, ResponseDefinition, Note, PepsDocData, VersionData, } from './core/schema';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAGnD,wBAAgB,OAAO,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,IAAI,CAE3E;AAGD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACzC,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAGxD,YAAY,EACV,aAAa,EACb,aAAa,EACb,SAAS,EACT,WAAW,EACX,UAAU,EACV,aAAa,EACb,QAAQ,EACR,UAAU,EACV,WAAW,EACX,kBAAkB,EAClB,IAAI,EACJ,WAAW,EACX,WAAW,GACZ,MAAM,eAAe,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PepsDoc - API documentation, beautifully automated.
|
|
4
|
+
*
|
|
5
|
+
* Usage:
|
|
6
|
+
* ```ts
|
|
7
|
+
* import express from 'express';
|
|
8
|
+
* import { pepsdoc } from 'pepsdoc';
|
|
9
|
+
*
|
|
10
|
+
* const app = express();
|
|
11
|
+
* pepsdoc(app, { title: 'My API' });
|
|
12
|
+
* app.listen(3000);
|
|
13
|
+
* // Docs at http://localhost:3000/docs
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.dataToLLM = exports.endpointToLLM = exports.METHOD_COLORS = exports.DEFAULT_CONFIG = exports.Storage = exports.expressAdapter = void 0;
|
|
18
|
+
exports.pepsdoc = pepsdoc;
|
|
19
|
+
const express_1 = require("./adapters/express");
|
|
20
|
+
// Main function — alias for Express adapter (default)
|
|
21
|
+
function pepsdoc(app, config) {
|
|
22
|
+
(0, express_1.expressAdapter)(app, config);
|
|
23
|
+
}
|
|
24
|
+
// Re-export everything
|
|
25
|
+
var express_2 = require("./adapters/express");
|
|
26
|
+
Object.defineProperty(exports, "expressAdapter", { enumerable: true, get: function () { return express_2.expressAdapter; } });
|
|
27
|
+
var storage_1 = require("./core/storage");
|
|
28
|
+
Object.defineProperty(exports, "Storage", { enumerable: true, get: function () { return storage_1.Storage; } });
|
|
29
|
+
var config_1 = require("./core/config");
|
|
30
|
+
Object.defineProperty(exports, "DEFAULT_CONFIG", { enumerable: true, get: function () { return config_1.DEFAULT_CONFIG; } });
|
|
31
|
+
Object.defineProperty(exports, "METHOD_COLORS", { enumerable: true, get: function () { return config_1.METHOD_COLORS; } });
|
|
32
|
+
var llm_1 = require("./export/llm");
|
|
33
|
+
Object.defineProperty(exports, "endpointToLLM", { enumerable: true, get: function () { return llm_1.endpointToLLM; } });
|
|
34
|
+
Object.defineProperty(exports, "dataToLLM", { enumerable: true, get: function () { return llm_1.dataToLLM; } });
|
|
35
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;GAaG;;;AAMH,0BAEC;AAND,gDAAoD;AAGpD,sDAAsD;AACtD,SAAgB,OAAO,CAAC,GAAY,EAAE,MAA+B;IACnE,IAAA,wBAAc,EAAC,GAA2C,EAAE,MAAM,CAAC,CAAC;AACtE,CAAC;AAED,uBAAuB;AACvB,8CAAoD;AAA3C,yGAAA,cAAc,OAAA;AACvB,0CAAyC;AAAhC,kGAAA,OAAO,OAAA;AAChB,wCAA8D;AAArD,wGAAA,cAAc,OAAA;AAAE,uGAAA,aAAa,OAAA;AACtC,oCAAwD;AAA/C,oGAAA,aAAa,OAAA;AAAE,gGAAA,SAAS,OAAA"}
|
package/package.json
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@pepshlr/pepdoc",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "API documentation, beautifully automated.",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"pepsdoc": "dist/bin/pepsdoc.js"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"dist",
|
|
12
|
+
"templates",
|
|
13
|
+
"ui/build"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc && cd ui && npm run build",
|
|
17
|
+
"build:core": "tsc",
|
|
18
|
+
"build:ui": "cd ui && npm run build",
|
|
19
|
+
"dev": "tsc --watch",
|
|
20
|
+
"prepublishOnly": "npm run build"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"api",
|
|
24
|
+
"documentation",
|
|
25
|
+
"swagger",
|
|
26
|
+
"openapi",
|
|
27
|
+
"docs",
|
|
28
|
+
"rest",
|
|
29
|
+
"api-docs"
|
|
30
|
+
],
|
|
31
|
+
"author": "Pedroohlr",
|
|
32
|
+
"license": "MIT",
|
|
33
|
+
"repository": {
|
|
34
|
+
"type": "git",
|
|
35
|
+
"url": "https://github.com/Pedroohlr/pepsdoc"
|
|
36
|
+
},
|
|
37
|
+
"engines": {
|
|
38
|
+
"node": ">=18"
|
|
39
|
+
},
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^25.5.0",
|
|
42
|
+
"typescript": "^6.0.2"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
# PepsDoc — AI Skill
|
|
2
|
+
|
|
3
|
+
You are tasked with documenting a backend API using the PepsDoc framework.
|
|
4
|
+
|
|
5
|
+
## What is PepsDoc?
|
|
6
|
+
|
|
7
|
+
PepsDoc is a documentation framework that stores API docs as JSON files in a `pepsdoc/` folder. These JSON files are rendered into a beautiful, modern documentation UI.
|
|
8
|
+
|
|
9
|
+
## How it works
|
|
10
|
+
|
|
11
|
+
1. The project has a `pepsdoc/` folder with:
|
|
12
|
+
- `pepsdoc.config.json` — General configuration
|
|
13
|
+
- `data/<version>/` — Folders for each API version (e.g. `data/v1/`)
|
|
14
|
+
- Inside each version folder: one `.json` file per endpoint group
|
|
15
|
+
|
|
16
|
+
2. You need to analyze the backend code and generate the JSON files.
|
|
17
|
+
|
|
18
|
+
## Step-by-step
|
|
19
|
+
|
|
20
|
+
### 1. Check if PepsDoc is initialized
|
|
21
|
+
|
|
22
|
+
Look for a `pepsdoc/pepsdoc.config.json` file. If it doesn't exist, run:
|
|
23
|
+
```bash
|
|
24
|
+
npx pepsdoc init
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### 2. Read the config
|
|
28
|
+
|
|
29
|
+
Read `pepsdoc/pepsdoc.config.json` to understand the project setup (title, versions, etc.).
|
|
30
|
+
|
|
31
|
+
### 3. Analyze the backend code
|
|
32
|
+
|
|
33
|
+
Scan the backend source code to find:
|
|
34
|
+
- All API routes/endpoints
|
|
35
|
+
- HTTP methods (GET, POST, PUT, PATCH, DELETE)
|
|
36
|
+
- Route parameters, query parameters
|
|
37
|
+
- Request body schemas
|
|
38
|
+
- Response schemas and status codes
|
|
39
|
+
- Authentication requirements
|
|
40
|
+
- Route groupings (by resource/feature)
|
|
41
|
+
|
|
42
|
+
### 4. Generate the JSON files
|
|
43
|
+
|
|
44
|
+
For each group of related endpoints (e.g. "Users", "Products", "Auth"), create a JSON file:
|
|
45
|
+
|
|
46
|
+
**File:** `pepsdoc/data/v1/<group-slug>.json`
|
|
47
|
+
|
|
48
|
+
**Schema:**
|
|
49
|
+
```json
|
|
50
|
+
{
|
|
51
|
+
"group": "Group Name",
|
|
52
|
+
"icon": "icon-name",
|
|
53
|
+
"order": 1,
|
|
54
|
+
"endpoints": [
|
|
55
|
+
{
|
|
56
|
+
"method": "GET | POST | PUT | PATCH | DELETE",
|
|
57
|
+
"path": "/api/v1/resource",
|
|
58
|
+
"summary": "Short description",
|
|
59
|
+
"description": "Detailed description of what this endpoint does.",
|
|
60
|
+
"headers": [
|
|
61
|
+
{
|
|
62
|
+
"name": "Authorization",
|
|
63
|
+
"type": "string",
|
|
64
|
+
"required": true,
|
|
65
|
+
"description": "Bearer token"
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
"queryParams": [
|
|
69
|
+
{
|
|
70
|
+
"name": "page",
|
|
71
|
+
"type": "number",
|
|
72
|
+
"required": false,
|
|
73
|
+
"description": "Page number",
|
|
74
|
+
"default": "1"
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
"pathParams": [
|
|
78
|
+
{
|
|
79
|
+
"name": "id",
|
|
80
|
+
"type": "string",
|
|
81
|
+
"required": true,
|
|
82
|
+
"description": "Resource ID"
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
"body": {
|
|
86
|
+
"contentType": "application/json",
|
|
87
|
+
"fields": [
|
|
88
|
+
{
|
|
89
|
+
"name": "name",
|
|
90
|
+
"type": "string",
|
|
91
|
+
"required": true,
|
|
92
|
+
"description": "User name"
|
|
93
|
+
}
|
|
94
|
+
],
|
|
95
|
+
"example": {
|
|
96
|
+
"name": "John Doe"
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"responses": [
|
|
100
|
+
{
|
|
101
|
+
"status": 200,
|
|
102
|
+
"description": "Success",
|
|
103
|
+
"example": {
|
|
104
|
+
"id": 1,
|
|
105
|
+
"name": "John Doe"
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"status": 400,
|
|
110
|
+
"description": "Bad request",
|
|
111
|
+
"example": {
|
|
112
|
+
"error": "Invalid input"
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
],
|
|
116
|
+
"tags": ["users"],
|
|
117
|
+
"deprecated": false,
|
|
118
|
+
"notes": [
|
|
119
|
+
{
|
|
120
|
+
"type": "info",
|
|
121
|
+
"title": "Rate limit",
|
|
122
|
+
"content": "This endpoint is rate limited to 100 requests per minute."
|
|
123
|
+
}
|
|
124
|
+
]
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
}
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### 5. Update the config if needed
|
|
131
|
+
|
|
132
|
+
If you identify multiple versions or need tabs, update `pepsdoc/pepsdoc.config.json`:
|
|
133
|
+
|
|
134
|
+
```json
|
|
135
|
+
{
|
|
136
|
+
"title": "My API",
|
|
137
|
+
"description": "Complete API documentation",
|
|
138
|
+
"basePath": "/docs",
|
|
139
|
+
"versions": [
|
|
140
|
+
{
|
|
141
|
+
"name": "v1",
|
|
142
|
+
"badge": "stable",
|
|
143
|
+
"badgeColor": "green",
|
|
144
|
+
"default": true
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
"tabs": [
|
|
148
|
+
{ "name": "REST API", "slug": "rest" },
|
|
149
|
+
{ "name": "Webhooks", "slug": "webhooks" }
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Integration with backend
|
|
155
|
+
|
|
156
|
+
If the backend uses **Node.js** (Express, Fastify, etc.), add PepsDoc to serve the docs:
|
|
157
|
+
|
|
158
|
+
```typescript
|
|
159
|
+
import express from 'express';
|
|
160
|
+
import { pepsdoc } from 'pepsdoc';
|
|
161
|
+
|
|
162
|
+
const app = express();
|
|
163
|
+
|
|
164
|
+
pepsdoc(app, {
|
|
165
|
+
title: 'My API',
|
|
166
|
+
version: '1.0.0',
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
app.listen(3000);
|
|
170
|
+
// Docs available at http://localhost:3000/docs
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
For **non-Node.js backends** (Python, Go, Java, etc.):
|
|
174
|
+
- Just generate the JSON files in `pepsdoc/data/`
|
|
175
|
+
- Run `npx pepsdoc build` to generate a static build
|
|
176
|
+
- Serve the `pepsdoc/.build/` folder as static files from your backend
|
|
177
|
+
|
|
178
|
+
## Important rules
|
|
179
|
+
|
|
180
|
+
- One JSON file per endpoint group (e.g. `users.json`, `products.json`)
|
|
181
|
+
- Use kebab-case for file names (e.g. `user-settings.json`)
|
|
182
|
+
- Always include realistic examples in request body and responses
|
|
183
|
+
- Group related endpoints together logically
|
|
184
|
+
- Set the `order` field to control sidebar ordering (lower = higher)
|
|
185
|
+
- Mark deprecated endpoints with `"deprecated": true`
|
|
186
|
+
- Use `notes` to add important information (rate limits, auth requirements, etc.)
|
|
187
|
+
|
|
188
|
+
## Supported languages
|
|
189
|
+
|
|
190
|
+
PepsDoc can document APIs written in ANY language. Just analyze the backend code (routes, controllers, handlers) and generate the JSON files following the schema above.
|
|
191
|
+
|
|
192
|
+
Common backend patterns to look for:
|
|
193
|
+
- **Express.js**: `app.get()`, `router.post()`, etc.
|
|
194
|
+
- **Fastify**: `fastify.get()`, route schemas
|
|
195
|
+
- **NestJS**: `@Get()`, `@Post()` decorators
|
|
196
|
+
- **Django/DRF**: `urlpatterns`, `ViewSet`, `@api_view`
|
|
197
|
+
- **Flask**: `@app.route()`, `@blueprint.route()`
|
|
198
|
+
- **FastAPI**: `@app.get()`, Pydantic models
|
|
199
|
+
- **Spring Boot**: `@GetMapping`, `@PostMapping`
|
|
200
|
+
- **Gin (Go)**: `r.GET()`, `r.POST()`
|
|
201
|
+
- **Actix/Axum (Rust)**: route definitions, handler functions
|
|
202
|
+
- **Laravel**: `Route::get()`, controllers
|
|
203
|
+
- **Rails**: `resources`, `get`, `post` in routes.rb
|