Skip to content

Commit 9d73891

Browse files
committed
update
1 parent 78f3286 commit 9d73891

51 files changed

Lines changed: 1595 additions & 474 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -169,11 +169,10 @@ npm start
169169
- Enable Pages for your repository (Settings -> Pages).
170170
- Use the repository workflow to build/deploy static output.
171171
- Optional one-command bootstrap:
172-
- `npx gitpagedocs --push --owner your-user --repo your-repository` — docs at `https://<owner>.github.io/<repo>/v/<version>/`
172+
- `npx gitpagedocs --push --owner your-user --repo your-repository` — docs at `https://<owner>.github.io/<repo>/<repo>/v/<version>/?lang=en` (e.g. `https://vidigal-code.github.io/energy-bill-ai-parser/energy-bill-ai-parser/v/1.0.0/?lang=en`); root redirects there; base path uses repo name so CSS/JS load correctly
173173
- `npx gitpagedocs --push --owner your-user --repo your-repository --path docs` — docs at `https://<owner>.github.io/<repo>/docs/v/<version>/`
174174
- This creates `.github/workflows/gitpagedocs-pages.yml`, sets `site.rendering`, commits generated artifacts, and pushes to `origin`.
175175
- The generated workflow clones the official `git-page-docs` runtime in CI, injects your `gitpagedocs/` folder, builds, and deploys to your GitHub Pages URL.
176-
- Root URL redirects to docs entrypoint (`/v/<version>`), so `https://<owner>.github.io/<repo>/` opens docs directly.
177176
- The workflow trigger uses your current git branch automatically.
178177
- After push, CLI also attempts to switch repository Pages source to **GitHub Actions** using `gh api` (if GitHub CLI is available and authenticated).
179178

@@ -191,7 +190,6 @@ gitpagedocs/
191190
versions/
192191
1.0.0/config.json
193192
1.0.0/{en,pt,es}/*.md
194-
1.0.0/{en,pt,es}/getting-started # HTML (no .html extension)
195193
1.0.0/{en,pt,es}/source-viewer # Source code viewer (GitHub-style)
196194
1.1.0/...
197195
1.1.1/...
@@ -300,10 +298,8 @@ All routes for accessing documentation files on the official site or self-hosted
300298
- Project overview:
301299
https://vidigal-code.github.io/git-page-docs/Vidigal-code/git-page-docs/v/1.0.0/?lang=en&menu=en&name=project-overview
302300

303-
**HTML pages** (by slug; pages combine MD + HTML when they share the same route id)
301+
**HTML pages** (by slug)
304302

305-
- Getting Started (HTML):
306-
https://vidigal-code.github.io/git-page-docs/Vidigal-code/git-page-docs/v/1.0.0/?lang=en&menu=en&name=getting-started
307303
- Source code viewer:
308304
https://vidigal-code.github.io/git-page-docs/Vidigal-code/git-page-docs/v/1.0.0/?lang=en&menu=en&name=source-viewer
309305

@@ -341,7 +337,7 @@ All routes for accessing documentation files on the official site or self-hosted
341337
|--------|-------------|
342338
| `--owner <user>` | GitHub owner (e.g. `Vidigal-code`) |
343339
| `--repo <repo>` | GitHub repository (e.g. `git-page-docs`) |
344-
| `--path <subpath>` | Subpath for docs (e.g. `docs`, `git-page-docs`) |
340+
| `--path <subpath>` | Subpath for docs (e.g. `docs`); without it, base path = repo name for correct asset loading on project sites |
345341
| `--output <dir>` | Output directory (default: `gitpagedocs` or `gitpagedocshome` with `--home`) |
346342
| `--search true\|false` | Enable/disable repository search (mainly for `--home`) |
347343
| `--layoutconfig` | Generate local layout templates in `gitpagedocs/layouts/` |

cli/builders/config-orchestrator.mjs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import { LAYOUTS, FALLBACK_LAYOUTS } from "../data/layouts.mjs";
44
import { DOCS } from "../content/docs.mjs";
5-
import { HTML_PAGES } from "../content/html-pages.mjs";
65
import { DOC_VERSIONS } from "../data/version-constants.mjs";
76
import { buildRootConfig } from "./root-config-builder.mjs";
87
import { buildVersionConfig } from "./version-config-builder.mjs";
@@ -22,7 +21,6 @@ export function buildConfigArtifacts(options = {}) {
2221

2322
const sourceViewerHtml = generateSourceViewerHtml(root);
2423
const docsHtml = {
25-
...HTML_PAGES,
2624
sourceViewer: { pt: sourceViewerHtml, en: sourceViewerHtml, es: sourceViewerHtml },
2725
};
2826

cli/builders/source-viewer.mjs

Lines changed: 74 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/** Generate GitHub-style source code viewer HTML from src/ and README.md */
1+
/** Generate GitHub-style source code viewer HTML from src/, cli/, and root config files */
22

33
import path from "node:path";
44
import { readFileSync, readdirSync, existsSync } from "node:fs";
@@ -19,7 +19,9 @@ function buildTreeFromKeys(fileKeys) {
1919
return root;
2020
}
2121

22-
function collectSourceFiles(root) {
22+
const ROOT_FILES = ["README.md", "package.json", "package-lock.json", "next.config.ts", "tsconfig.json", ".eslintrc.json"];
23+
24+
function collectSourceFiles(projectRoot) {
2325
const files = {};
2426
function scan(dir, prefix = "") {
2527
if (!existsSync(dir)) return;
@@ -33,21 +35,26 @@ function collectSourceFiles(root) {
3335
scan(fullPath, rel);
3436
} else {
3537
try {
36-
files[rel] = readFileSync(fullPath, "utf-8");
38+
const content = readFileSync(fullPath, "utf-8");
39+
files[rel] = content;
3740
} catch {
38-
// skip binary or unreadable files
41+
/* skip binary or unreadable */
3942
}
4043
}
4144
}
4245
}
43-
const readmePath = path.join(root, "README.md");
44-
if (existsSync(readmePath)) {
45-
try {
46-
files["README.md"] = readFileSync(readmePath, "utf-8");
47-
} catch {}
46+
for (const f of ROOT_FILES) {
47+
const p = path.join(projectRoot, f);
48+
if (existsSync(p)) {
49+
try {
50+
files[f] = readFileSync(p, "utf-8");
51+
} catch {}
52+
}
4853
}
49-
const srcDir = path.join(root, "src");
50-
scan(srcDir, "src");
54+
const srcDir = path.join(projectRoot, "src");
55+
const cliDir = path.join(projectRoot, "cli");
56+
if (existsSync(srcDir)) scan(srcDir, "src");
57+
if (existsSync(cliDir)) scan(cliDir, "cli");
5158
return files;
5259
}
5360

@@ -112,6 +119,13 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,san
112119
.sidebar .folder.collapsed .chevron{transform:rotate(-90deg)}
113120
.sidebar .children{margin-left:4px}
114121
.sidebar .children.hidden{display:none}
122+
.sidebar .search-wrap{padding:8px;border-bottom:1px solid var(--github-border-muted)}
123+
.sidebar .search-input{width:100%;padding:6px 10px;font-size:12px;border:1px solid var(--github-border);border-radius:6px;background:var(--github-bg);color:var(--github-fg);outline:none}
124+
.sidebar .search-input:focus{border-color:var(--github-accent)}
125+
.sidebar .search-input::placeholder{color:var(--github-fg-muted)}
126+
.sidebar .tree-actions{display:flex;gap:4px;padding:4px 8px;border-bottom:1px solid var(--github-border-muted)}
127+
.sidebar .tree-btn{padding:4px 8px;font-size:11px;border:1px solid var(--github-border);border-radius:4px;background:var(--github-bg-tertiary);color:var(--github-fg-muted);cursor:pointer}
128+
.sidebar .tree-btn:hover{color:var(--github-fg);background:var(--github-border)}
115129
116130
/* Content - GitHub file view */
117131
.content{flex:1;display:flex;flex-direction:column;overflow:hidden;background:var(--github-bg)}
@@ -150,7 +164,11 @@ body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,san
150164
<span class="file-name" id="breadcrumbFile">-</span>
151165
</div>
152166
<div class="layout">
153-
<aside class="sidebar" id="tree"></aside>
167+
<aside class="sidebar">
168+
<div class="search-wrap"><input type="text" class="search-input" id="searchInput" placeholder="Filter files..." autocomplete="off"/></div>
169+
<div class="tree-actions"><button class="tree-btn" id="expandAll">Expand all</button><button class="tree-btn" id="collapseAll">Collapse all</button></div>
170+
<div id="tree"></div>
171+
</aside>
154172
<main class="content">
155173
<div class="file-header" id="fileHeader" style="display:none">
156174
<span class="file-path" id="headerPath"></span>
@@ -169,12 +187,12 @@ var raw=el?el.textContent:"{}";
169187
var data=JSON.parse(raw);
170188
var files=data.files||{}, keys=data.fileKeys||[], treeData=data.tree||{};
171189
function esc(s){var d=document.createElement("div");d.textContent=s;return d.innerHTML}
172-
function getLang(path){
173-
if(path.endsWith(".ts")||path.endsWith(".tsx"))return"typescript";
174-
if(path.endsWith(".js")||path.endsWith(".mjs")||path.endsWith(".cjs"))return"javascript";
175-
if(path.endsWith(".json"))return"json";
176-
if(path.endsWith(".css"))return"css";
177-
if(path.endsWith(".md"))return"markdown";
190+
function getLang(p){
191+
if(p.endsWith(".ts")||p.endsWith(".tsx"))return"typescript";
192+
if(p.endsWith(".js")||p.endsWith(".mjs")||p.endsWith(".cjs"))return"javascript";
193+
if(p.endsWith(".json"))return"json";
194+
if(p.endsWith(".css"))return"css";
195+
if(p.endsWith(".md"))return"markdown";
178196
return"";
179197
}
180198
var viewMode="code";
@@ -257,22 +275,52 @@ function renderTree(node, parentEl, indent){
257275
}
258276
}
259277
}
260-
function buildTree(){
261-
var tree=document.getElementById("tree");
262-
if(Object.keys(treeData).length>0){
263-
renderTree(treeData,tree,0);
278+
function buildTreeFromKeys(keys){
279+
var root={};
280+
keys.forEach(function(key){
281+
var parts=key.split("/");
282+
var curr=root;
283+
for(var i=0;i<parts.length;i++){
284+
var part=parts[i];
285+
var isLast=i===parts.length-1;
286+
if(!curr[part])curr[part]=isLast?{path:key}:{};
287+
if(isLast)curr[part].path=key;
288+
else curr=curr[part];
289+
}
290+
});
291+
return root;
292+
}
293+
function buildTree(filterQuery){
294+
var treeEl=document.getElementById("tree");
295+
treeEl.innerHTML="";
296+
var filteredKeys=filterQuery?keys.filter(function(k){return k.toLowerCase().indexOf(filterQuery.toLowerCase())>=0;}):keys;
297+
var data=filteredKeys.length?buildTreeFromKeys(filteredKeys):{};
298+
if(Object.keys(data).length>0){
299+
renderTree(data,treeEl,0);
264300
}else{
265-
keys.sort();
266-
keys.forEach(function(k){
301+
filteredKeys.sort();
302+
filteredKeys.forEach(function(k){
267303
var div=document.createElement("div");
268304
div.className="file";
269305
div.dataset.path=k;
270-
div.innerHTML='<span class="icon">'+fileIcon()+'</span>'+esc(k);
306+
div.innerHTML='<span class="icon">'+fileIcon()+'</span>'+esc(k.split("/").pop());
271307
div.onclick=function(){selectFile(k)};
272-
tree.appendChild(div);
308+
treeEl.appendChild(div);
273309
});
274310
}
275311
}
312+
document.getElementById("searchInput").oninput=function(){
313+
var q=this.value.trim();
314+
buildTree(q);
315+
};
316+
document.getElementById("expandAll").onclick=function(){
317+
document.querySelectorAll(".sidebar .folder.collapsed").forEach(function(f){f.classList.remove("collapsed")});
318+
document.querySelectorAll(".sidebar .children.hidden").forEach(function(c){c.classList.remove("hidden")});
319+
};
320+
document.getElementById("collapseAll").onclick=function(){
321+
document.querySelectorAll(".sidebar .folder").forEach(function(f){f.classList.add("collapsed")});
322+
document.querySelectorAll(".sidebar .children").forEach(function(c){c.classList.add("hidden")});
323+
};
276324
buildTree();
277325
})();
278326
</script>

cli/builders/version-config-builder.mjs

Lines changed: 5 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import {
44
ROUTE_PATHS,
5-
HTML_PATHS,
65
VIDEO_IDS,
76
PAGE2_AUDIO,
87
SOURCE_VIEWER_META,
@@ -12,6 +11,7 @@ import {
1211
ROUTE_META_ID2,
1312
ROUTE_META_ID3,
1413
ROUTE_META_ID4,
14+
ROUTE_META_ID5,
1515
VIDEO_META_ID1,
1616
VIDEO_META_ID2,
1717
VIDEO_META_ID3,
@@ -20,12 +20,12 @@ import {
2020
} from "../data/route-metas.mjs";
2121
import { buildMdRoute, buildHtmlRoute, buildVideoRoute } from "./route-builders.mjs";
2222

23-
const ROUTE_METAS = { 1: ROUTE_META_ID1, 2: ROUTE_META_ID2, 3: ROUTE_META_ID3, 4: ROUTE_META_ID4 };
23+
const ROUTE_METAS = { 1: ROUTE_META_ID1, 2: ROUTE_META_ID2, 3: ROUTE_META_ID3, 4: ROUTE_META_ID4, 5: ROUTE_META_ID5 };
2424
const VIDEO_METAS = { 1: VIDEO_META_ID1, 2: VIDEO_META_ID2, 3: VIDEO_META_ID3, 4: VIDEO_META_ID4 };
2525

2626
function buildVersionMdRoutes(versionId) {
2727
const base = `gitpagedocs/docs/versions/${versionId}`;
28-
return [1, 2, 3, 4].map((id) => {
28+
return [1, 2, 3, 4, 5].map((id) => {
2929
const paths = ROUTE_PATHS[id];
3030
const meta = ROUTE_METAS[id];
3131
const pathByLang = {
@@ -40,19 +40,13 @@ function buildVersionMdRoutes(versionId) {
4040

4141
function buildVersionHtmlRoutes(versionId) {
4242
const base = `gitpagedocs/docs/versions/${versionId}`;
43-
const pathByLang1 = {
44-
pt: `${base}/pt/${HTML_PATHS[1].pt}`,
45-
en: `${base}/en/${HTML_PATHS[1].en}`,
46-
es: `${base}/es/${HTML_PATHS[1].es}`,
47-
};
4843
const pathByLangSource = {
4944
pt: `${base}/pt/source-viewer`,
5045
en: `${base}/en/source-viewer`,
5146
es: `${base}/es/source-viewer`,
5247
};
5348
return [
54-
buildHtmlRoute(versionId, 1, pathByLang1, ROUTE_META_ID1.titles, ROUTE_META_ID1.descriptions),
55-
buildHtmlRoute(versionId, 2, pathByLangSource, SOURCE_VIEWER_META.titles, SOURCE_VIEWER_META.descriptions, {
49+
buildHtmlRoute(versionId, 1, pathByLangSource, SOURCE_VIEWER_META.titles, SOURCE_VIEWER_META.descriptions, {
5650
container: "full",
5751
blockLink: true,
5852
}),
@@ -74,7 +68,7 @@ function buildVersionVideoRoutes(versionId) {
7468

7569
function buildVersionMenus(versionId) {
7670
const base = `gitpagedocs/docs/versions/${versionId}`;
77-
const menuMd = [1, 2, 3, 4].map((id) => ({
71+
const menuMd = [1, 2, 3, 4, 5].map((id) => ({
7872
id: id,
7973
pt: { title: ROUTE_METAS[id].titles.pt, "path-click": `${base}/pt/${ROUTE_PATHS[id].pt}` },
8074
en: { title: ROUTE_METAS[id].titles.en, "path-click": `${base}/en/${ROUTE_PATHS[id].en}` },
@@ -83,12 +77,6 @@ function buildVersionMenus(versionId) {
8377
const menuHtml = [
8478
{
8579
id: 1,
86-
pt: { title: "Primeiros passos (HTML)", "path-click": `${base}/pt/getting-started` },
87-
en: { title: "Getting Started (HTML)", "path-click": `${base}/en/getting-started` },
88-
es: { title: "Primeros pasos (HTML)", "path-click": `${base}/es/getting-started` },
89-
},
90-
{
91-
id: 2,
9280
pt: { title: "Código fonte", "path-click": `${base}/pt/source-viewer` },
9381
en: { title: "Source code", "path-click": `${base}/en/source-viewer` },
9482
es: { title: "Código fuente", "path-click": `${base}/es/source-viewer` },

0 commit comments

Comments
 (0)