forked from microsoft/fast
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(detail view): add detail view (microsoft#470)
* feat(detail view): add detail view * update tests * fix some complexity issues * fix a permutator test value * re-order imports * re-case readme markdown file names
- Loading branch information
Showing
93 changed files
with
26,445 additions
and
25,876 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,3 +71,6 @@ www/ | |
#Ignore VSCode | ||
.vscode/ | ||
.vs/ | ||
|
||
# tmp directories | ||
.tmp/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* Utility for converting README files to .tsx files. | ||
* Usage: node build/convert-readme.js %path% | ||
*/ | ||
const path = require("path"); | ||
const glob = require("glob"); | ||
const fs = require("fs"); | ||
const argv = require("yargs").argv; | ||
const MarkdownIt = require("markdown-it"); | ||
|
||
const srcDir = argv.src || "./src/**/README.md"; | ||
|
||
/** | ||
* Start and end file strings | ||
*/ | ||
const startFile = `// Generated file from ../../build | ||
/* tslint:disable */ | ||
import * as React from "react"; | ||
export default class Documentation extends React.Component<{}, {}> { | ||
public render(): JSX.Element { | ||
return ( | ||
<div style={{padding: "14px"}}>\n `; | ||
|
||
const endFile = `\n </div> | ||
); | ||
} | ||
}\n`; | ||
|
||
const md = new MarkdownIt({ | ||
html: true, | ||
linkify: true, | ||
typographer: true, | ||
xhtmlOut: true | ||
}); | ||
|
||
/** | ||
* All paths passed to the convert script | ||
*/ | ||
const paths = argv._; | ||
|
||
/** | ||
* Function to create string exports of a given path | ||
*/ | ||
function exportReadme(readmePath) { | ||
const readmePaths = path.resolve(process.cwd(), srcDir); | ||
|
||
glob(readmePaths, void(0), function(error, files) { | ||
files.forEach((filePath) => { | ||
let documentation = startFile; | ||
const markdown = fs.readFileSync(filePath, "utf8"); | ||
const exportPath = filePath.replace(/README\.md/, readmePath); | ||
documentation += md.render(markdown); | ||
documentation += endFile; | ||
|
||
if (!fs.existsSync(exportPath)){ | ||
fs.mkdirSync(exportPath); | ||
} | ||
|
||
fs.writeFileSync(path.resolve(exportPath, "documentation.tsx"), documentation); | ||
}); | ||
}); | ||
} | ||
|
||
/** | ||
* Convert all paths | ||
*/ | ||
if (Array.isArray(paths)) { | ||
paths.forEach(exportReadme); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Utility for copying readme to their dist folders. | ||
* Usage: node build/copy-readme.js | ||
*/ | ||
const path = require("path"); | ||
const fs = require("fs"); | ||
const glob = require("glob"); | ||
|
||
const rootDir = path.resolve(process.cwd()); | ||
const srcReadmePaths = "src/**/README.md"; | ||
const destDir = "dist"; | ||
|
||
/** | ||
* Function to copy readme files to their dist folder | ||
*/ | ||
function copyReadmeFiles() { | ||
const resolvedSrcReadmePaths = path.resolve(rootDir, srcReadmePaths); | ||
|
||
glob(resolvedSrcReadmePaths, void(0), function(error, files) { | ||
files.forEach((filePath) => { | ||
const destReadmePath = filePath.replace(/(\bsrc\b)(?!.*\1)/, destDir); | ||
fs.copyFileSync(filePath, destReadmePath); | ||
}); | ||
}); | ||
} | ||
|
||
/** | ||
* Copy all files | ||
*/ | ||
copyReadmeFiles(); |
Oops, something went wrong.