Skip to content
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

Move documentation to Docusaurus #9132

Merged
merged 46 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
ccf8675
init
laurent22 Oct 24, 2023
585dc6a
update
laurent22 Oct 24, 2023
fda9f0e
Merge branch 'dev' into doc-builder
laurent22 Oct 25, 2023
d978b2e
update
laurent22 Oct 25, 2023
5a6fa46
disable build script
laurent22 Oct 25, 2023
56b1c4c
disable build script
laurent22 Oct 25, 2023
b15f405
Merge branch 'dev' into doc-builder
laurent22 Oct 26, 2023
1b6f8c7
fixes
laurent22 Oct 26, 2023
439b14e
update
laurent22 Oct 27, 2023
8a38339
update
laurent22 Oct 27, 2023
3433979
update
laurent22 Oct 27, 2023
8a7fe96
fixes
laurent22 Oct 27, 2023
39b51b3
update
laurent22 Oct 27, 2023
f6ae866
update
laurent22 Oct 27, 2023
27acc85
update links
laurent22 Oct 27, 2023
09ba8b1
updare
laurent22 Oct 27, 2023
3fdbe6a
use yml lib
laurent22 Oct 27, 2023
1b2eec7
cleaup
laurent22 Oct 27, 2023
fee04d7
frontmatter
laurent22 Oct 27, 2023
9650a8d
updarte
laurent22 Oct 27, 2023
e2f7be3
update
laurent22 Oct 27, 2023
a9e882f
moving news to blog
laurent22 Oct 28, 2023
4950bee
news
laurent22 Oct 28, 2023
0926782
fix localisations
laurent22 Oct 28, 2023
bad3672
fix script
laurent22 Oct 28, 2023
46e335c
fix link
laurent22 Oct 28, 2023
52b43d7
update
laurent22 Oct 28, 2023
1931fda
donate links
laurent22 Oct 28, 2023
cb33f8d
various
laurent22 Oct 28, 2023
6216588
update links
laurent22 Oct 28, 2023
0c2f9f7
update links
laurent22 Oct 28, 2023
9990f79
fix links
laurent22 Oct 28, 2023
026426d
update
laurent22 Oct 28, 2023
13d58d8
build
laurent22 Oct 28, 2023
4e5b270
Merge branch 'dev' into doc-builder
laurent22 Oct 29, 2023
d1e7568
fix
laurent22 Oct 29, 2023
6339d9f
handle base url
laurent22 Oct 29, 2023
195505f
navbar
laurent22 Oct 29, 2023
c51126e
ci
laurent22 Oct 29, 2023
5c7c9d1
support local search
laurent22 Oct 29, 2023
b20927e
quotes
laurent22 Oct 29, 2023
954c12a
fixed hedaing
laurent22 Oct 29, 2023
440f64c
tweaks
laurent22 Oct 29, 2023
6a7bc22
news
laurent22 Oct 29, 2023
2cdf627
welcome
laurent22 Oct 29, 2023
b622c5c
fix
laurent22 Oct 29, 2023
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
Prev Previous commit
Next Next commit
quotes
  • Loading branch information
laurent22 committed Oct 29, 2023
commit b20927ec37e1bc63f552cb93a57569dc781f5c3c
5 changes: 5 additions & 0 deletions packages/doc-builder/src/css/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,9 @@
.sponsor-button:hover {
background-color: var(--ifm-color-primary-lighter);
color: white;
}

/* So that the code in markdown.md wraps. Otherwise the table takes too much space horizontally */
pre code {
white-space: pre-wrap;
}
2 changes: 1 addition & 1 deletion packages/tools/website/processDocs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const makeTestCases = () => {
for (const file of files) {
if (file.endsWith('.mdx')) continue;

// if (!file.endsWith('escaped_code.md')) continue;
// if (!file.endsWith('blockquotes.md')) continue;

const sourcePath = `${sampleDir}/${file}`;
const outputPath = `${sampleDir}/${basename(file, '.md')}.mdx`;
Expand Down
63 changes: 46 additions & 17 deletions packages/tools/website/processDocs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ interface Context {
processedFiles?: string[];
isNews?: boolean;
donateLinks?: string;
inQuote?: boolean;
}

const configs: Record<string, Config> = {
Expand Down Expand Up @@ -122,7 +123,9 @@ const escapeForMdx = (s: string): string => {
.replace(/`/g, '\\`');
};

const ParagraphBreak = '///PARAGRAPH_BREAK///';
const paragraphBreak = '///PARAGRAPH_BREAK///';
const blockQuoteStart = '///BLOCK_QUOTE_START///';
const blockQuoteEnd = '///BLOCK_QUOTE_END///';

const processToken = (token: any, output: string[], context: Context): void => {
if (!context.listStack) context.listStack = [];
Expand All @@ -140,13 +143,13 @@ const processToken = (token: any, output: string[], context: Context): void => {
const content: string[] = [];

if (type === 'heading_open') {
content.push(ParagraphBreak);
content.push(paragraphBreak);
content.push(`${token.markup} `);
} else if (type === 'heading_close') {
content.push(ParagraphBreak);
content.push(paragraphBreak);
} else if (type === 'paragraph_open' || type === 'paragraph_close') {
if (!currentList) {
content.push(ParagraphBreak);
content.push(paragraphBreak);
}
} else if (type === 'fence') {
context.inFence = true;
Expand All @@ -163,11 +166,13 @@ const processToken = (token: any, output: string[], context: Context): void => {
} else if (type === 'code_block') {
contentProcessed = true;
content.push(`\`\`\`\n${token.content}\`\`\``);
content.push(ParagraphBreak);
content.push(paragraphBreak);
} else if (type === 'strong_open' || type === 'strong_close') {
content.push('**');
} else if (type === 'em_open' || type === 'em_close') {
content.push('*');
} else if (type === 'blockquote_open' || type === 'blockquote_close') {
content.push(type === 'blockquote_open' ? blockQuoteStart : blockQuoteEnd);
} else if (type === 'table_open') {
context.currentTable = {
header: [],
Expand Down Expand Up @@ -202,9 +207,9 @@ const processToken = (token: any, output: string[], context: Context): void => {
context.currentTableContent = [];
} else if (type === 'table_close') {
const tableMd = markdownUtils.createMarkdownTable(context.currentTable.header, context.currentTable.rows);
content.push(ParagraphBreak);
content.push(paragraphBreak);
content.push(tableMd);
content.push(ParagraphBreak);
content.push(paragraphBreak);
context.currentTable = null;
} else if (type === 'bullet_list_open') {
context.listStarting = !context.listStack.length;
Expand All @@ -214,7 +219,7 @@ const processToken = (token: any, output: string[], context: Context): void => {
context.listStack.push({ type: 'number' });
} else if (type === 'bullet_list_close' || type === 'ordered_list_close') {
context.listStack.pop();
if (!context.listStack.length) content.push(ParagraphBreak);
if (!context.listStack.length) content.push(paragraphBreak);
} else if (type === 'list_item_open') {
if (!context.listStarting) content.push('\n');
context.listStarting = false;
Expand Down Expand Up @@ -242,7 +247,7 @@ const processToken = (token: any, output: string[], context: Context): void => {

if (type === 'fence') {
content.push('```');
content.push(ParagraphBreak);
content.push(paragraphBreak);
context.inFence = false;
}

Expand All @@ -264,25 +269,49 @@ const processToken = (token: any, output: string[], context: Context): void => {
const resolveParagraphBreaks = (output: string[]): string[] => {
if (!output.length) return output;

while (output.length && output[0] === ParagraphBreak) {
while (output.length && output[0] === paragraphBreak) {
output.splice(0, 1);
}

while (output.length && output[output.length - 1] === ParagraphBreak) {
while (output.length && output[output.length - 1] === paragraphBreak) {
output.pop();
}

let previous = '';
const newOutput: string[] = [];
for (const s of output) {
if (s === ParagraphBreak && previous === ParagraphBreak) continue;
newOutput.push(s === ParagraphBreak ? '\n\n' : s);
if (s === paragraphBreak && previous === paragraphBreak) continue;
newOutput.push(s === paragraphBreak ? '\n\n' : s);
previous = s;
}

return newOutput;
};

const resolveBlockQuotes = (output: string): string => {
if (!output) return output;

const lines = output.split('\n');
let inQuotes = false;
const quotedLines: string[] = [];
const newOutput: string[] = [];
for (const line of lines) {
if (line === blockQuoteStart) {
inQuotes = true;
} else if (line === blockQuoteEnd) {
inQuotes = false;
const s = quotedLines.join('\n').trim().split('\n').map(l => `> ${l}`).join('\n');
newOutput.push(s);
} else if (inQuotes) {
quotedLines.push(line);
} else {
newOutput.push(line);
}
}

return newOutput.join('\n');
};

const processUrls = (md: string) => {
md = md
.replace(/https:\/\/github.com\/laurent22\/joplin\/blob\/dev\/readme\/(.*)\/index\.md/g, '/help/$1')
Expand All @@ -298,24 +327,24 @@ export const processMarkdownDoc = (sourceContent: string, context: Context): str
html: true,
});

let lines: string[] = [];
let items: string[] = [];

markdownIt.core.ruler.push('converter', (state: StateCore) => {
const tokens = state.tokens;
// console.info(JSON.stringify(tokens, null, '\t'));
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
processToken(token, lines, context);
processToken(token, items, context);
}
});

const mdAndFrontMatter = stripOffFrontMatter(sourceContent);

markdownIt.render(mdAndFrontMatter.doc);

lines = resolveParagraphBreaks(lines);
items = resolveParagraphBreaks(items);

const output = processUrls(lines.join('').trim());
const output = resolveBlockQuotes(processUrls(items.join('').trim()));

return compileWithFrontMatter({
...mdAndFrontMatter,
Expand Down
5 changes: 5 additions & 0 deletions packages/tools/website/processDocsTestSamples/blockquotes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is a quote:

> "I never said that!"
>
> ― Albert Einstein
5 changes: 5 additions & 0 deletions packages/tools/website/processDocsTestSamples/blockquotes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
This is a quote:

> "I never said that!"
>
> ― Albert Einstein
1 change: 1 addition & 0 deletions renovate.json5
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"packages/app-mobile/android/app/build.gradle",
"packages/generate-plugin-doc/**",
"packages/plugins/**",
"packages/app-builder/**",
],
"ignoreDeps": [
"@babel/core",
Expand Down