forked from vison123/ant-design
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Revert "refactor with bisheng""
This reverts commit 7a07b12.
- Loading branch information
Showing
72 changed files
with
742 additions
and
726 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 |
---|---|---|
|
@@ -23,6 +23,6 @@ nohup.out | |
_site | ||
_data | ||
dist | ||
lib | ||
/lib | ||
elasticsearch-* | ||
config/base.yaml |
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
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
--- | ||
- order: 3 | ||
- title: 小数 | ||
order: 3 | ||
title: 小数 | ||
--- | ||
|
||
和原生的数字输入框一样,value 的精度由 step 的小数位数决定。 | ||
|
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
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
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
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
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
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
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
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
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
File renamed without changes.
File renamed without changes.
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,50 @@ | ||
const React = require('react'); | ||
const Link = require('react-router').Link; | ||
const toReactComponent = require('jsonml-to-react-component'); | ||
const JsonML = require('jsonml.js/lib/utils'); | ||
const VideoPlayer = require('./VideoPlayer'); | ||
const ImagePreview = require('./ImagePreview'); | ||
|
||
function isHeading(node) { | ||
return /h[1-6]/i.test(JsonML.getTagName(node)); | ||
} | ||
|
||
module.exports = () => { | ||
return { | ||
converters: [ | ||
[(node) => JsonML.isElement(node) && isHeading(node), (node, index) => { | ||
const children = JsonML.getChildren(node); | ||
return React.createElement(JsonML.getTagName(node), { | ||
key: index, | ||
id: children, | ||
...JsonML.getAttributes(node), | ||
}, [ | ||
<span key="title">{children.map((child) => toReactComponent(child))}</span>, | ||
<a href={`#${children}`} className="anchor" key="anchor">#</a>, | ||
]); | ||
}], | ||
[(node) => JsonML.isElement(node) && JsonML.getTagName(node) === 'video', (node, index) => | ||
<VideoPlayer video={JsonML.getAttributes(node)} key={index} />, | ||
], | ||
[(node) => JsonML.isElement(node) && JsonML.getTagName(node) === 'a' && !( | ||
JsonML.getAttributes(node).class || | ||
(JsonML.getAttributes(node).href && | ||
JsonML.getAttributes(node).href.indexOf('http') === 0) || | ||
/^#/.test(JsonML.getAttributes(node).href) | ||
), (node, index) => { | ||
return <Link to={JsonML.getAttributes(node).href} key={index}>{toReactComponent(JsonML.getChildren(node)[0])}</Link>; | ||
}], | ||
[(node) => { | ||
return JsonML.isElement(node) && | ||
JsonML.getTagName(node) === 'p' && | ||
JsonML.getTagName(JsonML.getChildren(node)[0]) === 'img' && | ||
/preview-img/gi.test(JsonML.getAttributes(JsonML.getChildren(node)[0]).class); | ||
}, (node, index) => { | ||
const imgs = JsonML.getChildren(node) | ||
.filter((img) => JsonML.isElement(img) && Object.keys(JsonML.getAttributes(img)).length > 0) | ||
.map((img) => JsonML.getAttributes(img)); | ||
return <ImagePreview imgs={imgs} key={index} />; | ||
}], | ||
], | ||
}; | ||
}; |
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,11 @@ | ||
const path = require('path'); | ||
const processDoc = require('./process-doc'); | ||
const processDemo = require('./process-demo'); | ||
|
||
module.exports = (markdownData) => { | ||
const isDemo = path.dirname(markdownData.meta.filename).endsWith('/demo'); | ||
if (isDemo) { | ||
return processDemo(markdownData); | ||
} | ||
return processDoc(markdownData); | ||
}; |
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,90 @@ | ||
const fs = require('fs'); | ||
const path = require('path'); | ||
const JsonML = require('jsonml.js/lib/utils'); | ||
const pkgPath = path.join(process.cwd(), 'package.json'); | ||
const pkgName = require(pkgPath).name; | ||
|
||
const nunjucks = require('nunjucks'); | ||
nunjucks.configure({ autoescape: false }); | ||
|
||
const babel = require('babel-core'); | ||
const babelrc = { | ||
presets: ['es2015', 'react'].map((m) => { | ||
return require.resolve(`babel-preset-${m}`); | ||
}), | ||
}; | ||
|
||
const tmpl = fs.readFileSync(path.join(__dirname, 'template.html')).toString(); | ||
|
||
function isStyleTag(node) { | ||
return node && JsonML.getTagName(node) === 'style'; | ||
} | ||
|
||
function getCode(node) { | ||
return JsonML.getChildren( | ||
JsonML.getChildren(node)[0] | ||
)[0]; | ||
} | ||
|
||
module.exports = (markdownData) => { | ||
const meta = markdownData.meta; | ||
meta.id = meta.filename.replace(/\.md$/, '').replace(/\//g, '-'); | ||
|
||
const contentChildren = JsonML.getChildren(markdownData.content); | ||
const chineseIntroStart = contentChildren.findIndex((node) => { | ||
return JsonML.getTagName(node) === 'h2' && | ||
JsonML.getChildren(node)[0] === 'zh-CN'; | ||
}); | ||
const englishIntroStart = contentChildren.findIndex((node) => { | ||
return JsonML.getTagName(node) === 'h2' && | ||
JsonML.getChildren(node)[0] === 'en-US'; | ||
}); | ||
const codeIndex = contentChildren.findIndex((node) => { | ||
return JsonML.getTagName(node) === 'pre' && | ||
JsonML.getAttributes(node).lang === 'jsx'; | ||
}); | ||
if (chineseIntroStart > -1 /* equal to englishIntroStart > -1 */) { | ||
markdownData.content = { | ||
'zh-CN': contentChildren.slice(chineseIntroStart + 1, englishIntroStart), | ||
'en-US': contentChildren.slice(englishIntroStart + 1, codeIndex), | ||
}; | ||
} else { | ||
markdownData.content = contentChildren.slice(0, codeIndex); | ||
} | ||
|
||
markdownData.highlightedCode = contentChildren[codeIndex].slice(0, 2); | ||
const preview = [ | ||
'pre', { lang: '__react' }, | ||
]; | ||
const componentsPath = path.join(process.cwd(), 'components'); | ||
preview.push([ | ||
'code', | ||
getCode(contentChildren[codeIndex]) | ||
.replace(`${pkgName}/lib`, componentsPath), | ||
]); | ||
markdownData.preview = preview; | ||
|
||
const styleNode = contentChildren.find((node) => { | ||
return isStyleTag(node) || | ||
(JsonML.getTagName(node) === 'pre' && JsonML.getAttributes(node).lang === 'css'); | ||
}); | ||
if (isStyleTag(styleNode)) { | ||
markdownData.style = JsonML.getChildren(styleNode)[0]; | ||
} else if (styleNode) { | ||
markdownData.style = getCode(styleNode); | ||
markdownData.highlightedStyle = JsonML.getAttributes(styleNode).highlighted; | ||
} | ||
|
||
if (meta.iframe) { | ||
const html = nunjucks.renderString(tmpl, { | ||
id: meta.id, | ||
style: markdownData.style, | ||
script: babel.transform(getCode(markdownData.preview), babelrc).code, | ||
}); | ||
const fileName = `demo-${Math.random()}.html`; | ||
fs.writeFile(path.join(process.cwd(), '_site', fileName), html); | ||
markdownData.src = path.join('/', fileName); | ||
} | ||
|
||
return markdownData; | ||
}; |
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,19 @@ | ||
const JsonML = require('jsonml.js/lib/utils'); | ||
|
||
module.exports = (markdownData) => { | ||
const contentChildren = JsonML.getChildren(markdownData.content); | ||
const apiStartIndex = contentChildren.findIndex((node) => { | ||
return JsonML.getTagName(node) === 'h2' && | ||
JsonML.getChildren(node)[0] === 'API'; | ||
}); | ||
|
||
if (apiStartIndex > -1) { | ||
const content = contentChildren.slice(0, apiStartIndex); | ||
markdownData.content = ['section'].concat(content); | ||
|
||
const api = contentChildren.slice(apiStartIndex); | ||
markdownData.api = ['section'].concat(api); | ||
} | ||
|
||
return markdownData; | ||
}; |
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,34 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Demo</title> | ||
<link rel="stylesheet" href="../index.css" /> | ||
<style> | ||
html, body { | ||
height: 100%; | ||
margin: 0; | ||
background: none; | ||
} | ||
{{ style }} | ||
</style> | ||
</head> | ||
<body> | ||
<div id="{{ id }}" class="code-box-demo"></div> | ||
<script> | ||
function require(module) { | ||
if (module === 'react-router') { | ||
return window.ReactRouter; | ||
} | ||
return window.parent[module]; | ||
} | ||
|
||
var React = require('react'); | ||
var ReactDOM = require('react-dom'); | ||
var mountNode = document.getElementById('{{ id }}'); | ||
</script> | ||
<script src="https://npmcdn.com/react-router/umd/ReactRouter.min.js"></script> | ||
<script> | ||
{{ script }} | ||
</script> | ||
</body> | ||
</html> |
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,34 @@ | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
source: [ | ||
'./components', | ||
'./docs', | ||
'CHANGELOG.md', // TODO: fix it in bisheng | ||
], | ||
theme: './site/theme', | ||
htmlTemplate: './site/theme/static/template.html', | ||
plugins: [ | ||
'bisheng-plugin-description', | ||
'bisheng-plugin-toc?maxDepth=2', | ||
'bisheng-plugin-react?lang=__react', | ||
'./site/bisheng-plugin-antd', | ||
], | ||
webpackConfig(config) { | ||
config.resolve.alias = { | ||
antd: process.cwd(), | ||
site: path.join(process.cwd(), 'site'), | ||
}; | ||
|
||
config.babel.plugins.push([ | ||
require.resolve('babel-plugin-antd'), | ||
{ | ||
style: true, | ||
libraryName: 'antd', | ||
libDir: 'components', | ||
}, | ||
]); | ||
|
||
return config; | ||
}, | ||
}; |
Oops, something went wrong.