Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ exports.onCreateNode = ({ node, actions }) => {
$(el).replaceWith(`<blockquote><p><strong>${type}:</strong> ${content}</p></blockquote>`);
});

/* Drop tables with no rows (usually from malformed asciidoc tables).
* turndown-plugin-gfm reads `table.rows[0].parentNode` and throws on them. */
$('table').each((_, el) => {
if (!$(el).find('tr').length) $(el).remove();
});

/* Get the cleaned HTML */
const cleanedHtml = $('body').html() || '';

Expand All @@ -55,7 +61,13 @@ exports.onCreateNode = ({ node, actions }) => {
const { tables } = require('turndown-plugin-gfm');
td.use(tables);

const markdownBody = td.turndown(cleanedHtml);
/* A conversion failure on one page must not fail the whole build */
let markdownBody = '';
try {
markdownBody = td.turndown(cleanedHtml);
} catch (err) {
console.warn(`Markdown conversion failed for "${title}" (${node.id}): ${err.message}`);
}

createNodeField({
node,
Expand Down
14 changes: 3 additions & 11 deletions modules/ROOT/pages/home.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,9 @@

++++
<div class="container">
<div class="header-banner">
<div class="radiance-bg">
<div class="blob blob-pink"></div>
<div class="blob blob-purple"></div>
<div class="blob blob-blue"></div>
<div class="blob blob-orange"></div>
<div class="blob blob-yellow"></div>
<div class="blob blob-purple-r"></div>
<div class="blob blob-teal"></div>
<div class="blob blob-wash-pink"></div>
<div class="blob blob-wash-blue"></div>
<div class="header-banner radiance-home-stage">
<div class="radiance-home" aria-hidden="true">
<div class="radiance-local" data-radiance-pattern="home" data-radiance-appearance="light"></div>
</div>
<div class="header-banner-text">
<h1>ThoughtSpot Embedded Documentation</h1>
Expand Down
16 changes: 5 additions & 11 deletions modules/tutorials/pages/guided-walkthroughs.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,11 @@

[.non-link]
++++
<div class="walkthroughs-page">
<div class="radiance-bg">
<div class="blob blob-pink"></div>
<div class="blob blob-purple"></div>
<div class="blob blob-blue"></div>
<div class="blob blob-orange"></div>
<div class="blob blob-yellow"></div>
<div class="blob blob-purple-r"></div>
<div class="blob blob-teal"></div>
<div class="blob blob-wash-pink"></div>
<div class="blob blob-wash-blue"></div>
<div class="walkthroughs-page radiance-home-stage">
<div class="walkthroughs-radiance" aria-hidden="true">
<div class="radiance-home">
<div class="radiance-local" data-radiance-pattern="home" data-radiance-appearance="light"></div>
</div>
</div>
<div class="walkthroughs-hero-text">
<h1>Quickstarts</h1>
Expand Down
42 changes: 31 additions & 11 deletions scripts/Converter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ interface TypeDocNode {
groups?: TypeDocGroup[];
comment?: TypeDocComment;
flags?: any;
indexSignature?: SignatureNode;
}

interface TypeDocComment {
Expand Down Expand Up @@ -597,22 +598,39 @@ class TypeDocParser {
return '';
};

// "Indexable" section: e.g. `[key: string]: any`
private handleIndexable = (node: TypeDocNode) => {
const signature = node.indexSignature;
if (!signature?.parameters?.length) return '';

const params = signature.parameters
.map((param) => `${param.name}: ${this.parseTypeDocType(param.type)}`)
.join(', ');

return `== Indexable\n\n[div boxDiv boxFullWidth]\n--\n\`[${params}]: ${this.parseTypeDocType(
signature.type,
)}\`\n--\n`;
};

// handles the Main page nodes (Enum, Class, Interface, Type Alias)
private handleMainNode = (node: TypeDocNode) => {
const pageTitle = `= ${node.name}`;

const mainPageContent = '';
let enumIndexContent = '\n\n[div boxDiv boxFullWidth]\n--\n';
// Special handling
if (['Enumeration', 'Class', 'Interface'].includes(node.kindString)) {
enumIndexContent += `${this.createTypeDocTable(
node.children?.map((childNode) =>
// The Index section is only emitted when it has a table to show.
// A table with no rows is dropped by Asciidoctor and breaks the markdown conversion.
let indexSection = '';
if (
['Enumeration', 'Class', 'Interface'].includes(node.kindString) &&
node.children?.length
) {
indexSection = `== Index\n\n\n[div boxDiv boxFullWidth]\n--\n${this.createTypeDocTable(
node.children.map((childNode) =>
this.convertNodeToLink(childNode),
) || [],
),
3,
)}`;
)}\n--\n\n`;
}
enumIndexContent += '\n--\n\n';

// Crate content for children ( Enum members , Parameters, Properties, etc..)
const groupContent = node.groups
Expand All @@ -631,11 +649,13 @@ class TypeDocParser {
pageTitle,
TypeDocInternalParser.parseComment(node.comment),
TypeDocInternalParser.parseTags(node.comment?.tags),
'== Index',
enumIndexContent,
this.handleIndexable(node),
indexSection,
mainPageContent,
groupContent,
].join('\n\n');
]
.filter((section) => section !== '')
.join('\n\n');
};

private handleEnumMember = (enumMember: EnumerationMemberNode) => {
Expand Down
Binary file added src/assets/fonts/BB-Roller-Mono-Regular.otf
Binary file not shown.
Loading
Loading