From 43ef3c8142bb94b85959d546bb3599b1485b551b Mon Sep 17 00:00:00 2001 From: Frank Li Date: Tue, 15 Aug 2017 16:55:38 -0700 Subject: [PATCH] Add comments --- lib/build-files.js | 1 + lib/copy-examples.js | 4 +++ lib/core/BlogPageLayout.js | 1 + lib/core/BlogPost.js | 1 + lib/core/BlogPostLayout.js | 1 + lib/core/CompLibrary.js | 1 + lib/core/Doc.js | 1 + lib/core/DocsLayout.js | 1 + lib/core/Head.js | 1 + lib/core/Marked.js | 2 ++ lib/core/Prism.js | 2 ++ lib/core/Site.js | 17 +----------- lib/core/nav/HeaderNav.js | 16 ++++++++--- lib/core/nav/SideNav.js | 3 +++ lib/publish-gh-pages.js | 2 ++ lib/server/generate.js | 52 ++++++++++++++++++++++-------------- lib/server/readCategories.js | 2 ++ lib/server/readMetadata.js | 9 +++++-- lib/server/server.js | 39 ++++++++++++++++----------- lib/server/translation.js | 11 ++++++++ lib/start-server.js | 1 + lib/write-translations.js | 8 +++--- 22 files changed, 114 insertions(+), 62 deletions(-) diff --git a/lib/build-files.js b/lib/build-files.js index fdd692161f..8dd2e5c755 100755 --- a/lib/build-files.js +++ b/lib/build-files.js @@ -28,5 +28,6 @@ if (!fs.existsSync(CWD + "/siteConfig.js")) { process.exit(1); } +// generate all static html files const generate = require("./server/generate.js"); generate(); diff --git a/lib/copy-examples.js b/lib/copy-examples.js index 792740f2ce..3a9a23e097 100755 --- a/lib/copy-examples.js +++ b/lib/copy-examples.js @@ -26,7 +26,10 @@ program .parse(process.argv); const outerFolder = path.basename(path.dirname(CWD)); + +// handles cases where feature is "translations", "versions" or neither/not present if (feature === "translations") { + // copy files for translations const folder = path.join(__dirname, "..", "examples", "translations"); if (fs.existsSync(CWD + "/../crowdin.yaml")) { console.log( @@ -74,6 +77,7 @@ if (feature === "translations") { } }); } else if (feature === "versions") { + // copy files for versions const folder = path.join(__dirname, "..", "examples", "versions"); let files = glob.sync(folder + "/**/*"); files.forEach(file => { diff --git a/lib/core/BlogPageLayout.js b/lib/core/BlogPageLayout.js index 6bfebc6b25..a5fbc271dd 100644 --- a/lib/core/BlogPageLayout.js +++ b/lib/core/BlogPageLayout.js @@ -14,6 +14,7 @@ const MetadataBlog = require("./MetadataBlog.js"); const React = require("react"); const Site = require("./Site.js"); +// used to generate entire blog pages, i.e. collection of truncated blog posts const BlogPageLayout = React.createClass({ getPageURL(page) { let url = this.props.config.baseUrl + "blog/"; diff --git a/lib/core/BlogPost.js b/lib/core/BlogPost.js index 71da9c3e3c..19ed673bdf 100644 --- a/lib/core/BlogPost.js +++ b/lib/core/BlogPost.js @@ -10,6 +10,7 @@ const Marked = require("./Marked.js"); const React = require("react"); +// inner blog component for the article itself, without sidebar/header/footer class BlogPost extends React.Component { renderContent() { let content = this.props.content; diff --git a/lib/core/BlogPostLayout.js b/lib/core/BlogPostLayout.js index 389a00d462..dcb1f4d01f 100644 --- a/lib/core/BlogPostLayout.js +++ b/lib/core/BlogPostLayout.js @@ -13,6 +13,7 @@ const BlogSidebar = require("./BlogSidebar.js"); const Container = require("./Container.js"); const Site = require("./Site.js"); +// used for entire blog posts, i.e., each written blog article with sidebar with site header/footer class BlogPostLayout extends React.Component { render() { return ( diff --git a/lib/core/CompLibrary.js b/lib/core/CompLibrary.js index c138962b88..33e730331d 100644 --- a/lib/core/CompLibrary.js +++ b/lib/core/CompLibrary.js @@ -11,6 +11,7 @@ const Marked = require("./Marked.js"); const Container = require("./Container.js"); const GridBlock = require("./GridBlock.js"); +// collection of other components to provide to users module.exports = { Marked: Marked, Container: Container, diff --git a/lib/core/Doc.js b/lib/core/Doc.js index 2b071f53cb..af57066436 100644 --- a/lib/core/Doc.js +++ b/lib/core/Doc.js @@ -10,6 +10,7 @@ const React = require("react"); const Marked = require("./Marked.js"); +// inner doc component for article itself class Doc extends React.Component { render() { let editLink = diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 4622892076..81911ace1b 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -14,6 +14,7 @@ const DocsSidebar = require("./DocsSidebar.js"); const Site = require("./Site.js"); const translation = require("../server/translation.js"); +// component used to generate whole webpage for docs, including sidebar/header/footer class DocsLayout extends React.Component { render() { const metadata = this.props.metadata; diff --git a/lib/core/Head.js b/lib/core/Head.js index 87be676ed4..587ebc7264 100644 --- a/lib/core/Head.js +++ b/lib/core/Head.js @@ -9,6 +9,7 @@ const React = require("react"); +// html head for each page class Head extends React.Component { render() { return ( diff --git a/lib/core/Marked.js b/lib/core/Marked.js index bb65d2488d..5ea91b2ec7 100644 --- a/lib/core/Marked.js +++ b/lib/core/Marked.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +/* Marked component is used to parse markdown to html */ + const React = require("react"); const Prism = require("./Prism.js"); const Header = require("./Header.js"); diff --git a/lib/core/Prism.js b/lib/core/Prism.js index 24743a082d..3030745466 100644 --- a/lib/core/Prism.js +++ b/lib/core/Prism.js @@ -7,6 +7,8 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +/* Prism is used by Marked to do code syntas highlighting */ + const React = require("react"); /** diff --git a/lib/core/Site.js b/lib/core/Site.js index dd111eef5e..fd9fee7947 100644 --- a/lib/core/Site.js +++ b/lib/core/Site.js @@ -16,23 +16,8 @@ const translation = require("../server/translation.js"); const CWD = process.cwd(); +// Component used to provide same head, header, footer, other scripts to all pages class Site extends React.Component { - /* - goes in body after navPusher - -