From dcd3361413e51e126c4674325875f06fea981687 Mon Sep 17 00:00:00 2001 From: Yangshun Tay Date: Wed, 23 Jan 2019 23:20:11 -0800 Subject: [PATCH] misc: update docs for new features --- docs/api-doc-markdown.md | 31 ++++++++++++++++++------------- v1/lib/core/Doc.js | 14 ++++++++------ v1/lib/static/css/main.css | 5 ++++- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/docs/api-doc-markdown.md b/docs/api-doc-markdown.md index 8865eae6fe..c1c805cfea 100644 --- a/docs/api-doc-markdown.md +++ b/docs/api-doc-markdown.md @@ -42,7 +42,7 @@ original_id: doc1 --- ``` -`custom_edit_url`: The URL for editing this document. If this field is not present, the document's edit URL will fall back to `editUrl` from optional fields of `siteConfig.js`. See [siteConfig.js](site-config.md) docs for more information. +`custom_edit_url`: The URL for editing this document. If this field is not present, the document's edit URL will fall back to `editUrl` from optional fields of `siteConfig.js`. See [siteConfig.js](api-site-config.md) docs for more information. For example: @@ -133,31 +133,36 @@ will lead to a table of contents of the functions: and each function will link to their corresponding sections in the page. -### Code tabs +### Language-specific Code Tabs -Docusaurus provides code tabs by default. To use code tabs, first, mark the start and end of a code tabs group, by using `` and `` respectively. -Secondly, start each tab with ``. +Display code in multiple programming languages using code tabs. First, mark the start and end of a code tabs group, by using `` and `` respectively in your markdown. Then start each tab with ``. -Example: +Adding the following code to your Markdown file: + + + +produces this: - + ```js -console.log("Hello, world!"); +console.log('Hello, world!'); ``` ```py -print("Hello, world!") +print('Hello, world!') ``` + ```C -#include +#include -int main(void) -{ - puts("Hello, world!"); +int main() { + printf("Hello World!"); + return 0; } ``` + ```Pascal program HelloWorld; @@ -165,8 +170,8 @@ begin WriteLn('Hello, world!'); end. ``` - + ## Syntax Highlighting diff --git a/v1/lib/core/Doc.js b/v1/lib/core/Doc.js index 3efff1b89c..c42fe493bf 100644 --- a/v1/lib/core/Doc.js +++ b/v1/lib/core/Doc.js @@ -21,13 +21,14 @@ const translateThisDoc = translate( const splitTabsToTitleAndContent = content => { const titles = content.match(//gms); const tabs = content.split(//gms); - if (!titles || !tabs || !titles.length || !tabs.length) return []; + if (!titles || !tabs || !titles.length || !tabs.length) { + return []; + } tabs.shift(); - const result = titles.map((title, idx) => ({ - title: title.substring(4, title.length - 3), + return titles.map((title, idx) => ({ + title: title.substring(4, title.length - 3).trim(), content: tabs[idx], })); - return result; }; // inner doc component for article itself @@ -39,7 +40,7 @@ class Doc extends React.Component { /(\n)(.*?)(\n)/gms, ); - const renderResult = contents.map(c => { + const renderResult = contents.map((c, index) => { if (c === '\n') { inCodeTabs = true; return null; @@ -55,8 +56,9 @@ class Doc extends React.Component { ); } - return {c}; + return {c}; }); + return renderResult; } diff --git a/v1/lib/static/css/main.css b/v1/lib/static/css/main.css index a328d068ca..a7378c3e5f 100644 --- a/v1/lib/static/css/main.css +++ b/v1/lib/static/css/main.css @@ -1604,8 +1604,11 @@ input::placeholder { display: none; } -.collapsible .arrow { +.collapsible { cursor: pointer; +} + +.collapsible .arrow { float: right; margin-right: 5px; transform: rotate(90deg);