├── src ├── icon.png ├── icon@2x.png ├── modifyDocsHTML.js ├── index.js ├── getData.js └── indexedFiles.js ├── .gitignore ├── Contents └── Info.plist ├── package.json └── README.md /src/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenglou/react-dash/HEAD/src/icon.png -------------------------------------------------------------------------------- /src/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chenglou/react-dash/HEAD/src/icon@2x.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules 3 | Contents/Resources 4 | src/docs 5 | *.docset 6 | *.tgz 7 | -------------------------------------------------------------------------------- /Contents/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleIdentifier 6 | Facebook 7 | CFBundleName 8 | React 9 | DocSetPlatformFamily 10 | React 11 | isDashDocset 12 | 13 | isJavaScriptEnabled 14 | 15 | dashIndexFilePath 16 | react/index.html 17 | 18 | 19 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-dash", 3 | "version": "0.0.0", 4 | "description": "React documentation source for [Dash](http://kapeli.com/dash)", 5 | "repository": { 6 | "type": "git", 7 | "url": "https://github.com/chenglou/react-dash" 8 | }, 9 | "main": "src/index.js", 10 | "dependencies": { 11 | "cheerio": "^0.17.0", 12 | "lodash.flatten": "^2.4.1", 13 | "sequelize": "^2.0.0", 14 | "sqlite3": "^3.0.5" 15 | }, 16 | "devDependencies": {}, 17 | "scripts": { 18 | "test": "echo \"Error: no test specified\" && exit 1" 19 | }, 20 | "author": "chenglou", 21 | "license": "ISC" 22 | } 23 | -------------------------------------------------------------------------------- /src/modifyDocsHTML.js: -------------------------------------------------------------------------------- 1 | var cheerio = require('cheerio'); 2 | var fs = require('fs'); 3 | var indexedFiles = require('./indexedFiles'); 4 | 5 | // remove the left column and the nav bar so that it fits dash's usually small 6 | // browser screen 7 | indexedFiles.forEach(function(a, i) { 8 | var path = __dirname + '/../Contents/Resources/Documents/react/docs/' + 9 | a.name + '.html'; 10 | var src = fs.readFileSync(path, 'utf8'); 11 | var $ = cheerio.load(src); 12 | 13 | $('.nav-main').remove(); 14 | $('.nav-docs').remove(); 15 | $('.container').attr('style', 'min-width:inherit;padding-top:0'); 16 | $('.wrap').attr('style', 'width:inherit;'); 17 | $('.inner-content').attr('style', 'float:none;margin:auto;'); 18 | fs.writeFileSync(path, $.html(), 'utf8'); 19 | }); 20 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | var getData = require('./getData'); 2 | var Sequelize = require('sequelize'); 3 | 4 | // to see the relevant doc pages we crawl, check indexedFiles.js 5 | 6 | // db ops 7 | var sequelize = new Sequelize('database', null, null, { 8 | dialect: 'sqlite', 9 | storage: __dirname + '/../Contents/Resources/docSet.dsidx', 10 | }); 11 | 12 | var searchIndex = sequelize.define( 13 | 'searchIndex', 14 | { 15 | id: {type: Sequelize.INTEGER, autoIncrement: true}, 16 | name: {type: Sequelize.STRING}, 17 | type: {type: Sequelize.STRING}, 18 | path: {type: Sequelize.STRING}, 19 | }, 20 | { 21 | freezeTableName: true, 22 | timestamps: false, 23 | } 24 | ); 25 | 26 | searchIndex.sync().then(function() { 27 | getData().forEach(function(header) { 28 | var si = searchIndex.build({ 29 | name: header.name, 30 | type: header.type, 31 | path: header.path 32 | }); 33 | si.save(); 34 | }); 35 | }); 36 | -------------------------------------------------------------------------------- /src/getData.js: -------------------------------------------------------------------------------- 1 | var cheerio = require('cheerio'); 2 | var fs = require('fs'); 3 | var flatten = require('lodash.flatten'); 4 | var indexedFiles = require('./indexedFiles'); 5 | 6 | // this assumes build1.sh has been run, and the react docs fetched into 7 | // Contents/Resources/Documents/React 8 | function getData() { 9 | var res = indexedFiles.map(function(a) { 10 | var path = __dirname + '/../Contents/Resources/Documents/react/docs/' + 11 | a.name + '.html'; 12 | var src = fs.readFileSync(path, 'utf-8'); 13 | var $ = cheerio.load(src); 14 | 15 | var $headers = $('.inner-content h3, .inner-content h4'); 16 | 17 | var names = []; 18 | var hashes = []; 19 | 20 | $headers.each(function(i, e) { 21 | var name = $($(e).contents().get(1)).text(); 22 | names.push(name.trim()); 23 | 24 | var hash = $($(e).find('a').get(1)).attr('href'); 25 | // cherrio bug? hash includes the bla.html prefix 26 | hashes.push(hash.slice(hash.indexOf('#') + 1)); 27 | }); 28 | 29 | // gosh I'm glad that DOM API's over 30 | 31 | var url = 'react/docs/' + a.name + '.html#'; 32 | 33 | var res = names.map(function(n, i) { 34 | return { 35 | name: n, 36 | type: a.type, 37 | path: url + hashes[i], 38 | }; 39 | }); 40 | 41 | if (a.extraHeaders) { 42 | res = res.concat(a.extraHeaders.map(function(e) { 43 | return { 44 | name: e[0], 45 | type: a.type, 46 | path: url + e[1], 47 | }; 48 | })); 49 | } 50 | 51 | return res; 52 | }); 53 | 54 | return flatten(res); 55 | } 56 | 57 | module.exports = getData; 58 | -------------------------------------------------------------------------------- /src/indexedFiles.js: -------------------------------------------------------------------------------- 1 | var indexedFiles = [ 2 | { 3 | name: 'animation', 4 | type: 'Component', 5 | extraHeaders: [ 6 | ['ReactCSSTransitionGroup', 'high-level-api-reactcsstransitiongroup'], 7 | ['ReactTransitionGroup', 'low-level-api-reacttransitiongroup'], 8 | ] 9 | }, 10 | {name: 'two-way-binding-helpers', type: 'Mixin'}, 11 | { 12 | name: 'class-name-manipulation', 13 | type: 'Extension', 14 | extraHeaders: [ 15 | ['classSet', ''], 16 | ] 17 | }, 18 | {name: 'test-utils', type: 'Test'}, 19 | {name: 'clone-with-props', type: 'Extension'}, 20 | {name: 'create-fragment', type: 'Extension'}, 21 | { 22 | name: 'update', 23 | type: 'Extension', 24 | extraHeaders: [ 25 | ['update.push', 'available-commands'], 26 | ['update.unshift', 'available-commands'], 27 | ['update.splice', 'available-commands'], 28 | ['update.set', 'available-commands'], 29 | ['update.merge', 'available-commands'], 30 | ['update.apply', 'available-commands'], 31 | ] 32 | }, 33 | { 34 | name: 'pure-render-mixin', 35 | type: 'Mixin', 36 | extraHeaders: [ 37 | ['PureRenderMixin', ''] 38 | ] 39 | }, 40 | {name: 'perf', type: 'Extension'}, 41 | {name: 'top-level-api', type: 'Method'}, 42 | {name: 'component-api', type: 'Method'}, 43 | {name: 'component-specs', type: 'Interface'}, 44 | {name: 'tags-and-attributes', type: 'Tag'}, 45 | {name: 'events', type: 'Event'}, 46 | { 47 | name: 'glossary', 48 | type: 'Interface', 49 | extraHeaders: [ 50 | ['Elements', 'react-elements'], 51 | ['Nodes', 'react-nodes'], 52 | ['Components', 'react-components'], 53 | ] 54 | }, 55 | ]; 56 | 57 | module.exports = indexedFiles; 58 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [React](http://facebook.github.io/react/) Dash Documentation 2 | 3 | # Warning! 4 | React docset is now officially maintained by Dash and is avaiable _since Dash 3.1.0_. There's no need for this library anymore. Thus, it's now deprecated! 5 | 6 | Below is the old instruction. 7 | 8 | === 9 | 10 | **If you're looking for React documentations for Dash**: they're already in Preferences -> Downloads -> User Contributed. This repo is used to generate those docs. You don't need to touch it unless you want to contribute to it. 11 | 12 | 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. 13 | 14 | **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. 15 | 16 | ## Instructions 17 | 18 | Prerequisites: wget, node and sqlite3. For OS X: 19 | 20 | brew install wget node sqlite3 21 | 22 | Clone this repo, `cd` into it and do: 23 | 24 | npm install 25 | chmod 777 build.sh 26 | ./build.sh 27 | 28 | The script will: 29 | 30 | - Fetch the newest released React documentation from http://facebook.github.io/react/. 31 | - Parse the doc site into a new SQLite database for Dash. The list of files are hardcoded. Please check `src/index.js` for more detail. 32 | - Bundle up the result in a React.docset. 33 | 34 | 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): 35 | 36 | tar --exclude='.DS_Store' -cvzf React.tgz React.docset 37 | --------------------------------------------------------------------------------