@raycast/generate-docs
Advanced tools
Comparing version 0.8.6 to 0.8.8
29
index.js
@@ -60,10 +60,18 @@ #!/usr/bin/env node | ||
const assetsPath = path.join(docsPath, ".gitbook", "assets"); | ||
const utilsPath = path.join(docsPath, "utils-reference"); | ||
const anchors = []; | ||
const assets = []; | ||
let hasUtilsDocs = false; | ||
await iterateOverDocs(docsPath, (filepath, content) => { | ||
if (filepath.startsWith(path.join(docsPath, ".gitbook", "assets"))) { | ||
if (filepath.startsWith(assetsPath)) { | ||
assets.push(filepath); | ||
} | ||
if (filepath.startsWith(utilsPath)) { | ||
hasUtilsDocs = true; | ||
} | ||
if (content) { | ||
@@ -113,3 +121,8 @@ anchors.push({ file: filepath, anchor: "", formattedAnchor: "" }); | ||
checkLinks(filepath, content, anchors); | ||
checkLinks( | ||
filepath, | ||
content, | ||
anchors, | ||
hasUtilsDocs ? undefined : utilsPath | ||
); | ||
const imagesFound = checkImages(filepath, content, assets); | ||
@@ -203,3 +216,3 @@ assetsFound = { ...assetsFound, ...imagesFound }; | ||
/** check that every relative links points to an existing document */ | ||
function checkLinks(filepath, content, anchors) { | ||
function checkLinks(filepath, content, anchors, utilsPath) { | ||
const links = [...content.matchAll(linkRegex)].map((x) => ({ | ||
@@ -218,2 +231,8 @@ file: filepath, | ||
: path.resolve(path.dirname(x.file), x.link); | ||
if (utilsPath && linkPath.startsWith(utilsPath)) { | ||
// ignore the link to the utils when we don't have them | ||
return; | ||
} | ||
if ( | ||
@@ -267,2 +286,6 @@ anchors.every( | ||
if (!propsType.children) { | ||
console.log(filepath, name) | ||
} | ||
const props = propsType.children | ||
@@ -269,0 +292,0 @@ .filter( |
{ | ||
"name": "@raycast/generate-docs", | ||
"version": "0.8.6", | ||
"version": "0.8.8", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
29884
909