Skip to content

Commit 783c38c

Browse files
committed
Init
0 parents  commit 783c38c

File tree

7 files changed

+221
-0
lines changed

7 files changed

+221
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
node_modules
3+
Contents/Resources
4+
src/docs
5+
*.docset
6+
*.tgz

Contents/Info.plist

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>CFBundleIdentifier</key>
6+
<string>Facebook</string>
7+
<key>CFBundleName</key>
8+
<string>React</string>
9+
<key>DocSetPlatformFamily</key>
10+
<string>React</string>
11+
<key>isDashDocset</key>
12+
<true/>
13+
<key>isJavaScriptEnabled</key>
14+
<true/>
15+
<key>dashIndexFilePath</key>
16+
<string>react/index.html</string>
17+
</dict>
18+
</plist>

README.md

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
[React](http://facebook.github.io/react/) Dash Documentation
2+
3+
This repo is used to generate the docs for [Dash](http://kapeli.com/dash). To update the docset, please read the instructions [here](https://github.com/Kapeli/Dash-User-Contributions#contribute-a-new-docset) (more specifically, "Set up your directory structure"). To generate the docset for your Dash-User-Contributions pull quest, you'd use this repo.
4+
5+
**Note**: if you do wish to update the docset, please notify me by [opening an issue](https://github.com/chenglou/react-dash/issues/new). I'd like to double check everything before you send it off to the Dash repo.
6+
7+
## Instructions
8+
9+
Prerequisites: wget, node and sqlite3. For OS X:
10+
11+
brew install wget node sqlite3
12+
13+
Clone this repo, cd into it and do:
14+
15+
npm install
16+
cd Contents
17+
mkdir -p Resources/Documents/React
18+
cd Resources/Documents
19+
wget -m -p -E -k -np http://facebook.github.io/react/
20+
mv facebook.github.io/react React
21+
rm -rf facebook.github.io
22+
cd ..
23+
sqlite3 docSet.dsidx 'CREATE TABLE searchIndex(id INTEGER PRIMARY KEY, name TEXT, type TEXT, path TEXT)'
24+
sqlite3 docSet.dsidx 'CREATE UNIQUE INDEX anchor ON searchIndex (name, type, path)'
25+
cd ../../src
26+
mkdir -p docs
27+
28+
Now, copy over some files to `src/docs` from [here](https://github.com/facebook/react/tree/master/docs/docs). (Try `curl` or `git clone` the React repo). Here's a list of the currently indexed files:
29+
30+
- 09.1-animation.md
31+
- 09.2-form-input-binding-sugar.md
32+
- 09.3-class-name-manipulation.md
33+
- 09.4-test-utils.md
34+
- 09.5-clone-with-props.md
35+
- 09.6-update.md
36+
- 09.7-pure-render-mixin.md
37+
- 09.8-perf.md
38+
- ref-01-top-level-api.md
39+
- ref-02-component-api.md
40+
- ref-03-component-specs.md
41+
- ref-04-tags-and-attributes.md
42+
- ref-05-events.md
43+
44+
Some of these files' Dash headers are hardcoded. Please check `src/index.js` for more detail.
45+
46+
Go back to `src/`.
47+
48+
node index.js
49+
cd ../
50+
mkdir React.docset
51+
cp -r Contents React.docset
52+
cp src/icon* React.docset
53+
54+
Test the output by clicking on React.docset (importing it into Dash). Then, like it said on [Dash User Contributions](https://github.com/Kapeli/Dash-User-Contributions#contribute-a-new-docset):
55+
56+
tar --exclude='.DS_Store' -cvzf React.tgz React.docset

package.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "table-generator",
3+
"version": "0.0.0",
4+
"description": "",
5+
"main": "index.js",
6+
"dependencies": {
7+
"lodash.flatten": "^2.4.1",
8+
"sequelize": "^1.7.9",
9+
"slug": "^0.5.0",
10+
"sqlite3": "^2.2.7"
11+
},
12+
"devDependencies": {},
13+
"scripts": {
14+
"test": "echo \"Error: no test specified\" && exit 1"
15+
},
16+
"author": "chenglou",
17+
"license": "ISC"
18+
}

src/icon.png

3.98 KB
Loading

src/[email protected]

5.92 KB
Loading

src/index.js

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
var Sequelize = require('sequelize');
2+
3+
var fs = require('fs');
4+
var flatten = require('lodash.flatten');
5+
var slug = require('slug');
6+
7+
var indexedFiles = [
8+
{
9+
name: '09.1-animation',
10+
type: 'Component',
11+
extraHeaders: [
12+
['ReactCSSTransitionGroup', 'high-level-api-reactcsstransitiongroup'],
13+
['ReactTransitionGroup', 'low-level-api-reacttransitiongroup'],
14+
]
15+
},
16+
{name: '09.2-form-input-binding-sugar', type: 'Mixin'},
17+
{
18+
name: '09.3-class-name-manipulation',
19+
type: 'Extension',
20+
extraHeaders: [
21+
['classSet', ''],
22+
]
23+
},
24+
{name: '09.4-test-utils', type: 'Test'},
25+
{name: '09.5-clone-with-props', type: 'Extension'},
26+
{
27+
name: '09.6-update',
28+
type: 'Extension',
29+
extraHeaders: [
30+
['update.push', 'available-commands'],
31+
['update.unshift', 'available-commands'],
32+
['update.splice', 'available-commands'],
33+
['update.set', 'available-commands'],
34+
['update.merge', 'available-commands'],
35+
['update.apply', 'available-commands'],
36+
]
37+
},
38+
{
39+
name: '09.7-pure-render-mixin',
40+
type: 'Mixin',
41+
extraHeaders: [
42+
['PureRenderMixin', '']
43+
]
44+
},
45+
{name: '09.8-perf', type: 'Extension'},
46+
{name: 'ref-01-top-level-api', type: 'Method'},
47+
{name: 'ref-02-component-api', type: 'Method'},
48+
{name: 'ref-03-component-specs', type: 'Interface'},
49+
{name: 'ref-04-tags-and-attributes', type: 'Tag'},
50+
{name: 'ref-05-events', type: 'Event'},
51+
];
52+
53+
function convertHeader(s) {
54+
return slug(s.toLowerCase());
55+
}
56+
57+
var headerRegex = /#{3,} .+/g;
58+
59+
function getHeaders() {
60+
var res = indexedFiles.map(function(a, i) {
61+
var path = './docs/' + a.name + '.md';
62+
var md = fs.readFileSync(path, 'utf-8');
63+
64+
var headers = md.match(headerRegex);
65+
headers = headers === null ? [] : headers;
66+
67+
var url = 'react/docs/' + a.name.replace(/.+?\d+-/, '') + '.html#';
68+
69+
var res = headers.map(function(h) {
70+
var header = h.slice(h.indexOf(' ') + 1);
71+
return {
72+
name: header,
73+
type: a.type,
74+
path: url + convertHeader(header),
75+
};
76+
});
77+
78+
if (a.extraHeaders) {
79+
res = res.concat(a.extraHeaders.map(function(e) {
80+
return {
81+
name: e[0],
82+
type: a.type,
83+
path: url + e[1],
84+
};
85+
}));
86+
}
87+
88+
return res;
89+
});
90+
91+
return flatten(res);
92+
}
93+
94+
// db ops
95+
var sequelize = new Sequelize('database', null, null, {
96+
dialect: 'sqlite',
97+
storage: '../Contents/Resources/docSet.dsidx',
98+
});
99+
100+
var searchIndex = sequelize.define(
101+
'searchIndex',
102+
{
103+
id: {type: Sequelize.INTEGER, autoIncrement: true},
104+
name: {type: Sequelize.STRING},
105+
type: {type: Sequelize.STRING},
106+
path: {type: Sequelize.STRING},
107+
},
108+
{
109+
freezeTableName: true,
110+
timestamps: false,
111+
}
112+
);
113+
114+
searchIndex.sync().success(function() {
115+
getHeaders().forEach(function(header) {
116+
var si = searchIndex.build({
117+
name: header.name,
118+
type: header.type,
119+
path: header.path
120+
});
121+
si.save();
122+
});
123+
});

0 commit comments

Comments
 (0)