-
Notifications
You must be signed in to change notification settings - Fork 5
Docs llm copy issue #1250
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
Docs llm copy issue #1250
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -101,6 +101,65 @@ async function parseFrontmatter(markdownContent) { | |
| return yaml.parse(yamlNode.value); | ||
| } | ||
|
|
||
| function convertAttributesToMarkdown(content: string): string { | ||
| // Extract attributes from <Attributes> tags | ||
| const attributesRegex = /<Attributes>([\s\S]*?)<\/Attributes>/g; | ||
|
|
||
| return content.replace(attributesRegex, (match, attributesContent) => { | ||
| // Extract individual attributes - handle multiline attributes | ||
| const attributeRegex = /<Attribute\s+([\s\S]*?)\/>/g; | ||
| const attributes: Array<{ | ||
| name: string; | ||
| type?: string; | ||
| description?: string; | ||
| required: boolean; | ||
| }> = []; | ||
|
|
||
| let attrMatch; | ||
| while ((attrMatch = attributeRegex.exec(attributesContent)) !== null) { | ||
| const attrString = attrMatch[1]; | ||
|
|
||
| // Extract name | ||
| const nameMatch = attrString.match(/name="([^"]+)"/); | ||
| const name = nameMatch ? nameMatch[1] : ""; | ||
|
|
||
| // Extract type | ||
| const typeMatch = attrString.match(/type="([^"]+)"/); | ||
| const type = typeMatch ? typeMatch[1] : ""; | ||
|
|
||
| // Extract description | ||
| const descMatch = attrString.match(/description="([^"]+)"/); | ||
| const description = descMatch ? descMatch[1] : ""; | ||
|
|
||
| // Check if required | ||
| const required = attrString.includes("isRequired"); | ||
|
|
||
| if (name) { | ||
| attributes.push({ | ||
| name, | ||
| type, | ||
| description, | ||
| required, | ||
| }); | ||
| } | ||
| } | ||
|
|
||
| if (attributes.length === 0) return ""; | ||
|
|
||
| // Create markdown table | ||
| let table = "\n| Property | Type | Description | Required |\n"; | ||
| table += "| --- | --- | --- | --- |\n"; | ||
|
|
||
| for (const attr of attributes) { | ||
| table += `| \`${attr.name}\` | \`${attr.type || "any"}\` | ${ | ||
| attr.description | ||
| } | ${attr.required ? "Yes" : "No"} |\n`; | ||
| } | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Pipe characters in descriptions break markdown tablesMedium Severity The |
||
|
|
||
| return table; | ||
| }); | ||
| } | ||
|
|
||
| async function writePublicMarkdown(slug, content) { | ||
| try { | ||
| const publicPath = path.join( | ||
|
|
@@ -130,8 +189,33 @@ async function getMarkdownContent(slug) { | |
| } | ||
|
|
||
| if (fs.existsSync(markdownPath)) { | ||
| const content = fs.readFileSync(markdownPath, "utf-8"); | ||
| let content = fs.readFileSync(markdownPath, "utf-8"); | ||
| const frontmatter = await parseFrontmatter(content); | ||
|
|
||
| // Check if content contains a Typedoc component reference | ||
| const typedocMatch = content.match(/<Typedoc\s+file="([^"]+)"\s*\/>/); | ||
| if (typedocMatch) { | ||
| const typedocFile = typedocMatch[1]; | ||
| const typedocPath = path.join( | ||
| process.cwd(), | ||
| "typedocs", | ||
| `${typedocFile}.mdx`, | ||
| ); | ||
|
|
||
| if (fs.existsSync(typedocPath)) { | ||
| let typedocContent = fs.readFileSync(typedocPath, "utf-8"); | ||
| // Remove frontmatter from typedoc content if present | ||
| typedocContent = typedocContent.replace( | ||
| /^---\n[\s\S]*?\n---\n\n?/, | ||
| "", | ||
| ); | ||
| // Convert Attributes components to markdown tables | ||
| typedocContent = convertAttributesToMarkdown(typedocContent); | ||
| // Replace the Typedoc component with the actual content | ||
| content = content.replace(typedocMatch[0], typedocContent); | ||
| } | ||
| } | ||
|
|
||
| return { | ||
| ...frontmatter, | ||
| description: frontmatter?.description || "", | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSX template literal descriptions silently dropped
Medium Severity
The regex
/description="([^"]+)"/only matches double-quoted string values. However, some typedoc files use JSX template literal syntax likedescription={\...`}(e.g., inms-teams-auth-button.mdx`). These descriptions won't match the regex and will default to an empty string, silently dropping the actual description content from the generated markdown table.