-
-
Notifications
You must be signed in to change notification settings - Fork 289
feat(docs): site health + AI-citation fixes (A1, A2, A8 …) #897
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
dhananjay6561
wants to merge
26
commits into
keploy:main
Choose a base branch
from
dhananjay6561:feat/ai-citation-health
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
f34e09b
fix(docs): add image to Article schema (A1)
dhananjay6561 88f8864
fix(docs): differentiate page title from h1 (A2)
dhananjay6561 52568df
fix(docs): add alt text to images missing it (A8)
dhananjay6561 23c9c94
style(docs): prettier formatting on api-testing-functions/variables
dhananjay6561 0301cd3
style(docs): prettier (2.8.8) on DocItem
dhananjay6561 7f927db
style(docs): format DocItem for CI prettier 3.9.6
dhananjay6561 b4d42f0
feat(docs): specialize doc schema to TechArticle/APIReference (Doc2)
dhananjay6561 563815c
fix(docs): unique meta descriptions for 6 pages (A7)
dhananjay6561 98e2a80
style(docs): prettier 3.9.6 on beta-testing.md
dhananjay6561 ae50868
feat(docs): add structured data to bespoke pages (Doc2)
dhananjay6561 46a9ac3
feat(docs): emit FAQPage schema for FAQ docs (Doc2/AI4)
dhananjay6561 03ffef4
feat(docs): consolidate JSON-LD into one @id-linked entity graph (Doc2)
dhananjay6561 429537c
fix(docs): resolve residual SEO audit items (A8, A9)
dhananjay6561 4ffad60
docs(A5): expand thin SCM PR-agent page with capabilities + related l…
dhananjay6561 f7ae0b9
docs(A5): expand Windows/WSL install page with prerequisites + relate…
dhananjay6561 8f505e6
docs(A4): add "Related Terms" cross-links to all 37 glossary pages
dhananjay6561 3104c08
docs(A4): add "Related" cross-links to running-keploy docs
dhananjay6561 a292fef
docs(A4): add "Related" cross-links to quickstart sample apps
dhananjay6561 96e82dc
docs(A4): add "Related" cross-links to keploy-cloud docs
dhananjay6561 6e6b4be
docs(A4): add "Related" cross-links to keploy-explained docs
dhananjay6561 cf53f7f
docs(A4): add "Related" cross-links to ci-cd docs
dhananjay6561 881f832
docs(A4): add "Related" cross-links to server install + SDK docs
dhananjay6561 a66ad50
docs(AI4): add HowTo schema to CI/CD integration guides
dhananjay6561 668e9df
docs(AI4): add HowTo schema to language SDK install guides
dhananjay6561 78440b9
docs(AI4): add HowTo schema to Linux/Windows install guides
dhananjay6561 409fbff
ci(vale): accept technical terms flagged on changed lines
dhananjay6561 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,120 @@ | ||
| #!/usr/bin/env node | ||
| /** | ||
| * Verifies the JSON-LD graph in the built site. | ||
| * | ||
| * The @id-based consolidation only pays off if every bare {"@id": "..."} | ||
| * reference resolves to a node actually defined on the same page -- an | ||
| * unresolved reference is worse than the inline duplicate it replaced, | ||
| * because consumers get a dangling pointer instead of an entity. This walks | ||
| * the built HTML and fails on unparseable JSON-LD or dangling references. | ||
| * | ||
| * Usage: node scripts/verify-schema-graph.js [buildDir] | ||
| */ | ||
| const fs = require("fs"); | ||
| const path = require("path"); | ||
|
|
||
| const buildDir = process.argv[2] || "build"; | ||
| const SKIP_VERSIONS = ["/1.0.0/", "/2.0.0/"]; | ||
|
|
||
| function findHtml(dir, out = []) { | ||
| for (const entry of fs.readdirSync(dir, {withFileTypes: true})) { | ||
| const full = path.join(dir, entry.name); | ||
| if (entry.isDirectory()) { | ||
| findHtml(full, out); | ||
| } else if (entry.name === "index.html") { | ||
| out.push(full); | ||
| } | ||
| } | ||
| return out; | ||
| } | ||
|
|
||
| // The build inlines JSON-LD into <script type="application/ld+json">. Entities | ||
| // are HTML-escaped by React, so unescape before parsing. | ||
| const SCRIPT_RE = | ||
| /<script[^>]*type="application\/ld\+json"[^>]*>([\s\S]*?)<\/script>/g; | ||
|
|
||
| function unescapeHtml(s) { | ||
| return s | ||
| .replace(/"/g, '"') | ||
| .replace(/'/g, "'") | ||
| .replace(/'/g, "'") | ||
| .replace(/</g, "<") | ||
| .replace(/>/g, ">") | ||
| .replace(/&/g, "&"); | ||
| } | ||
|
|
||
| // Collect every node that declares an @id, and every bare {"@id"} reference. | ||
| function walk(node, defined, referenced) { | ||
| if (Array.isArray(node)) { | ||
| node.forEach((n) => walk(n, defined, referenced)); | ||
| return; | ||
| } | ||
| if (!node || typeof node !== "object") { | ||
| return; | ||
| } | ||
| const keys = Object.keys(node).filter((k) => k !== "@context"); | ||
| if (node["@id"]) { | ||
| // A node carrying only "@id" is a reference; anything else defines it. | ||
| if (keys.length === 1) { | ||
| referenced.add(node["@id"]); | ||
| } else { | ||
| defined.add(node["@id"]); | ||
| } | ||
| } | ||
| for (const key of keys) { | ||
| walk(node[key], defined, referenced); | ||
| } | ||
| } | ||
|
|
||
| const files = findHtml(buildDir).filter( | ||
| (f) => !SKIP_VERSIONS.some((v) => f.includes(v)) | ||
| ); | ||
|
|
||
| let parseErrors = 0; | ||
| let dangling = 0; | ||
| let blocks = 0; | ||
| const typeCounts = new Map(); | ||
|
|
||
| for (const file of files) { | ||
| const html = fs.readFileSync(file, "utf8"); | ||
| const defined = new Set(); | ||
| const referenced = new Set(); | ||
| let match; | ||
| SCRIPT_RE.lastIndex = 0; | ||
| while ((match = SCRIPT_RE.exec(html))) { | ||
| blocks += 1; | ||
| let parsed; | ||
| try { | ||
| parsed = JSON.parse(unescapeHtml(match[1])); | ||
| } catch (err) { | ||
| parseErrors += 1; | ||
| console.error(`INVALID JSON-LD ${file}\n ${err.message}`); | ||
| continue; | ||
| } | ||
| const graph = parsed["@graph"] || parsed; | ||
| walk(graph, defined, referenced); | ||
| for (const n of Array.isArray(graph) ? graph : [graph]) { | ||
| const t = n && n["@type"]; | ||
| if (typeof t === "string") { | ||
| typeCounts.set(t, (typeCounts.get(t) || 0) + 1); | ||
| } | ||
| } | ||
| } | ||
| for (const ref of referenced) { | ||
| if (!defined.has(ref)) { | ||
| dangling += 1; | ||
| console.error(`DANGLING @id ${file}\n ${ref}`); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| console.log(`\nPages scanned: ${files.length}`); | ||
| console.log(`JSON-LD blocks: ${blocks}`); | ||
| console.log(`Invalid JSON: ${parseErrors}`); | ||
| console.log(`Dangling @id refs: ${dangling}`); | ||
| console.log("\nTop-level @type distribution:"); | ||
| for (const [type, count] of [...typeCounts].sort((a, b) => b[1] - a[1])) { | ||
| console.log(` ${String(count).padStart(5)} ${type}`); | ||
| } | ||
|
|
||
| process.exit(parseErrors || dangling ? 1 : 0); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.