"
77 | ]
78 | }
79 |
--------------------------------------------------------------------------------
/screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/dignifiedquire/clean-documentation-theme/2a01efb8dcdc3176805f74790f25213d3e3a062c/screenshot.png
--------------------------------------------------------------------------------
/src/components/app.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const PropTypes = require('prop-types')
5 | const Radium = require('radium')
6 | const {StyleRoot} = Radium
7 | const {Container, Column, Row} = require('radium-bootstrap-grid')
8 |
9 | const Header = require('./header')
10 | const Nav = require('./navigation')
11 | const Content = require('./content')
12 | const {lineHeight} = require('./styles')
13 | const Utils = require('../utils')
14 |
15 | const hasMembers = (doc) => {
16 | const m = doc.members
17 | return m.static.length > 0 ||
18 | m.instance.length > 0 ||
19 | (m.events && m.events.length > 0)
20 | }
21 |
22 | const App = ({options, docs}) => {
23 | const containerStyle = {
24 | paddingTop: lineHeight(4)
25 | }
26 |
27 | const navItems = docs.map((doc) => {
28 | return {
29 | name: doc.name,
30 | members: hasMembers(doc) ? doc.members : null
31 | }
32 | })
33 |
34 | const navStyle = {
35 | position: 'fixed',
36 | height: '80%',
37 | maxWidth: '300px'
38 | }
39 |
40 | const utils = new Utils(options, docs)
41 | const radiumConfig = {
42 | userAgent: 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
43 | }
44 | return (
45 |
46 |
50 |
51 |
52 |
53 |
57 |
60 |
61 |
67 |
70 |
71 |
72 |
73 |
74 | )
75 | }
76 |
77 | App.propTypes = {
78 | options: PropTypes.object.isRequired,
79 | docs: PropTypes.array.isRequired
80 | }
81 |
82 | module.exports = Radium(App)
83 |
--------------------------------------------------------------------------------
/src/components/content/description.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const {lineHeight} = require('../styles')
8 | const Utils = require('../../utils')
9 |
10 | const Description = ({content, utils}) => {
11 | const rendered = {
12 | __html: utils.md(content)
13 | }
14 |
15 | const style = {
16 | marginTop: lineHeight(0.5),
17 | marginBottom: lineHeight(0.5)
18 | }
19 |
20 | return (
21 |
24 | )
25 | }
26 |
27 | Description.propTypes = {
28 | content: PropTypes.oneOfType([
29 | PropTypes.string,
30 | PropTypes.object
31 | ]).isRequired,
32 | utils: PropTypes.instanceOf(Utils).isRequired
33 | }
34 |
35 | module.exports = Radium(Description)
36 |
--------------------------------------------------------------------------------
/src/components/content/example.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 |
9 | const Example = ({caption, content, utils}) => {
10 | let renderedCaption
11 |
12 | if (caption) {
13 | renderedCaption = (
14 |
15 | )
16 | }
17 |
18 | const rendered = {
19 | __html: utils.highlight(content)
20 | }
21 |
22 | return (
23 |
24 |
Example
25 | {renderedCaption}
26 |
27 |
29 |
30 |
31 | )
32 | }
33 |
34 | Example.propTypes = {
35 | caption: PropTypes.object,
36 | content: PropTypes.oneOfType([
37 | PropTypes.string,
38 | PropTypes.object
39 | ]).isRequired,
40 | utils: PropTypes.instanceOf(Utils).isRequired
41 | }
42 |
43 | module.exports = Radium(Example)
44 |
--------------------------------------------------------------------------------
/src/components/content/examples.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Example = require('./example')
8 | const Utils = require('../../utils')
9 |
10 | const Examples = ({list, utils}) => {
11 | if (!list || !list.length) {
12 | return null
13 | }
14 |
15 | return (
16 |
17 | {list.map((example, i) => (
18 |
23 | ))}
24 |
25 | )
26 | }
27 |
28 | Examples.propTypes = {
29 | list: PropTypes.array,
30 | utils: PropTypes.instanceOf(Utils).isRequired
31 | }
32 |
33 | module.exports = Radium(Examples)
34 |
--------------------------------------------------------------------------------
/src/components/content/extends.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 |
9 | const Extends = ({list, utils}) => {
10 | if (!list || !list.length) {
11 | return null
12 | }
13 |
14 | const wrapperStyle = {
15 | display: 'inline'
16 | }
17 |
18 | const supers = {
19 | __html: list.map((sup) => {
20 | return utils.autolink(sup.name)
21 | }).join(', ') + '.'
22 | }
23 |
24 | return (
25 |
26 | Extends
27 |
28 |
29 | )
30 | }
31 |
32 | Extends.propTypes = {
33 | list: PropTypes.array,
34 | utils: PropTypes.instanceOf(Utils).isRequired
35 | }
36 |
37 | module.exports = Radium(Extends)
38 |
--------------------------------------------------------------------------------
/src/components/content/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const {Style} = Radium
6 | const PropTypes = require('prop-types')
7 |
8 | const Utils = require('../../utils')
9 | const {contentStyles} = require('../styles')
10 |
11 | const Section = require('./section')
12 |
13 | const Content = ({utils, docs}) => {
14 | return (
15 |
16 |
17 | {docs.map((section, i) => (
18 |
25 | ))}
26 |
27 | )
28 | }
29 |
30 | Content.propTypes = {
31 | utils: PropTypes.instanceOf(Utils).isRequired,
32 | docs: PropTypes.array.isRequired
33 | }
34 |
35 | module.exports = Radium(Content)
36 |
--------------------------------------------------------------------------------
/src/components/content/param.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 | const Type = require('./type')
9 | const {lineHeight} = require('../styles')
10 |
11 | const ListItem = Radium(({
12 | name,
13 | val,
14 | defaultVal,
15 | description,
16 | utils
17 | }) => {
18 | const descriptionStyle = {
19 | display: 'inline-block'
20 | }
21 | const liStyle = {
22 | paddingBottom: lineHeight(0.5)
23 | }
24 |
25 | return (
26 |
27 |
32 | :
33 |
36 |
37 | )
38 | })
39 |
40 | const Param = ({
41 | name,
42 | typeVal,
43 | defaultVal,
44 | description,
45 | properties,
46 | utils
47 | }) => {
48 | let propertyList
49 |
50 | if (properties && properties.length > 0) {
51 | propertyList = properties.map((p) => (
52 |
59 | ))
60 | }
61 |
62 | return (
63 |
64 |
71 | {propertyList}
72 |
73 | )
74 | }
75 |
76 | Param.propTypes = {
77 | name: PropTypes.string.isRequired,
78 | typeVal: PropTypes.any,
79 | defaultVal: PropTypes.string,
80 | description: PropTypes.object,
81 | properties: PropTypes.array,
82 | utils: PropTypes.instanceOf(Utils).isRequired
83 | }
84 |
85 | module.exports = Radium(Param)
86 |
--------------------------------------------------------------------------------
/src/components/content/params.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 | const Param = require('./param')
9 |
10 | const Params = ({params, utils}) => {
11 | if (!params || !params.length) {
12 | return null
13 | }
14 |
15 | const listStyle = {
16 | listStyle: 'none',
17 | marginLeft: 0,
18 | paddingLeft: 0
19 | }
20 |
21 | return (
22 |
23 |
Parameters
24 |
25 | {params.map((param) => (
26 |
34 | ))}
35 |
36 |
37 | )
38 | }
39 |
40 | Params.propTypes = {
41 | params: PropTypes.array,
42 | utils: PropTypes.instanceOf(Utils).isRequired
43 | }
44 |
45 | module.exports = Radium(Params)
46 |
--------------------------------------------------------------------------------
/src/components/content/returns.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 |
9 | const Returns = ({list, utils}) => {
10 | if (!list || !list.length) {
11 | return null
12 | }
13 |
14 | return (
15 |
16 |
Returns
17 | {list.map((ret, i) => (
18 |
19 |
20 | {ret.description ? (
21 | ) : null}
25 |
26 | ))}
27 |
28 | )
29 | }
30 |
31 | Returns.propTypes = {
32 | list: PropTypes.array,
33 | utils: PropTypes.instanceOf(Utils).isRequired
34 | }
35 |
36 | module.exports = Radium(Returns)
37 |
--------------------------------------------------------------------------------
/src/components/content/section-group.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 | const SectionMember = require('./section-member')
9 |
10 | const SectionGroup = ({name, utils, members, parent}) => {
11 | const style = {
12 | textTransform: 'uppercase'
13 | }
14 |
15 | let displayParent
16 | if (name === 'static') {
17 | displayParent = parent
18 | } else if (name === 'instance') {
19 | displayParent = parent + '.prototype'
20 | }
21 |
22 | return (
23 |
24 |
{name}
25 | {members.map((m, i) => (
26 |
34 | ))}
35 |
36 | )
37 | }
38 |
39 | SectionGroup.propTypes = {
40 | name: PropTypes.string.isRequired,
41 | members: PropTypes.array.isRequired,
42 | parent: PropTypes.string.isRequired,
43 | utils: PropTypes.instanceOf(Utils).isRequired
44 | }
45 |
46 | module.exports = Radium(SectionGroup)
47 |
--------------------------------------------------------------------------------
/src/components/content/section-member.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 | const Signature = require('./signature')
9 | const Description = require('./description')
10 | const Examples = require('./examples')
11 | const Params = require('./params')
12 | const SourceLink = require('./source-link')
13 | const Returns = require('./returns')
14 | const Throws = require('./throws')
15 | const Extends = require('./extends')
16 | const See = require('./see')
17 |
18 | const {lineHeight} = require('../styles')
19 |
20 | const SectionMember = ({
21 | namespace,
22 | name,
23 | description,
24 | member,
25 | parent,
26 | utils
27 | }) => {
28 | let displayParent
29 |
30 | if (parent) {
31 | displayParent = parent + '.'
32 | }
33 |
34 | let displayName = displayParent + name
35 | if (name === 'constructor') {
36 | displayName = name
37 | }
38 |
39 | const style = {
40 | marginBottom: lineHeight(2)
41 | }
42 |
43 | return (
44 |
45 |
46 |
47 | {displayName}
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | )
60 | }
61 |
62 | SectionMember.propTypes = {
63 | namespace: PropTypes.string,
64 | name: PropTypes.string.isRequired,
65 | description: PropTypes.oneOfType([
66 | PropTypes.string,
67 | PropTypes.object
68 | ]),
69 | member: PropTypes.object,
70 | parent: PropTypes.string.isRequired,
71 | utils: PropTypes.instanceOf(Utils).isRequired
72 | }
73 |
74 | module.exports = Radium(SectionMember)
75 |
--------------------------------------------------------------------------------
/src/components/content/section.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 | const {lineHeight} = require('../styles')
9 | const SectionGroup = require('./section-group')
10 | const SourceLink = require('./source-link')
11 | const Extends = require('./extends')
12 | const See = require('./see')
13 | const Params = require('./params')
14 | const Examples = require('./examples')
15 | const Returns = require('./returns')
16 | const Throws = require('./throws')
17 |
18 | const Section = ({
19 | name,
20 | namespace,
21 | description,
22 | section,
23 | utils
24 | }) => {
25 | const members = section.members
26 | const memberTypes = [
27 | 'static',
28 | 'instance',
29 | 'events'
30 | ].filter((key) => {
31 | return members[key] && members[key].length > 0
32 | })
33 |
34 | const style = {
35 | marginBottom: lineHeight(4)
36 | }
37 |
38 | return (
39 |
40 |
41 |
42 | {name}
43 |
44 |
45 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | {memberTypes.map((type, i) => (
56 |
62 | ))}
63 |
64 | )
65 | }
66 |
67 | Section.propTypes = {
68 | name: PropTypes.string.isRequired,
69 | namespace: PropTypes.string,
70 | description: PropTypes.oneOfType([
71 | PropTypes.string,
72 | PropTypes.object
73 | ]).isRequired,
74 | section: PropTypes.object,
75 | utils: PropTypes.instanceOf(Utils).isRequired
76 | }
77 |
78 | module.exports = Radium(Section)
79 |
--------------------------------------------------------------------------------
/src/components/content/see.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const remark = require('remark')()
6 | const PropTypes = require('prop-types')
7 |
8 | const Utils = require('../../utils')
9 |
10 | const See = ({tags, utils}) => {
11 | if (!tags || !tags.length) {
12 | return null
13 | }
14 |
15 | const list = tags.filter((tag) => tag.title === 'see')
16 |
17 | if (!list.length) {
18 | return null
19 | }
20 |
21 | const wrapperStyle = {
22 | display: 'inline'
23 | }
24 |
25 | return (
26 |
27 |
See
28 |
29 | {list.map((link, i) => (
30 | -
31 |
35 |
36 | ))}
37 |
38 |
39 | )
40 | }
41 |
42 | See.propTypes = {
43 | tags: PropTypes.array,
44 | utils: PropTypes.instanceOf(Utils).isRequired
45 | }
46 |
47 | module.exports = Radium(See)
48 |
--------------------------------------------------------------------------------
/src/components/content/signature.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 |
9 | const Signature = ({member, utils}) => {
10 | const content = {
11 | __html: utils.signature(member)
12 | }
13 |
14 | return (
15 |
16 |
18 |
19 | )
20 | }
21 |
22 | Signature.propTypes = {
23 | member: PropTypes.object,
24 | utils: PropTypes.instanceOf(Utils).isRequired
25 | }
26 |
27 | module.exports = Radium(Signature)
28 |
--------------------------------------------------------------------------------
/src/components/content/source-link.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const GoCode = require('react-icons/lib/go/code')
8 |
9 | const SourceLink = ({context}) => {
10 | if (!context || !context.github) {
11 | return null
12 | }
13 |
14 | const style = {
15 | float: 'right'
16 | }
17 |
18 | return (
19 |
23 |
24 |
25 | )
26 | }
27 |
28 | SourceLink.propTypes = {
29 | context: PropTypes.object
30 | }
31 |
32 | module.exports = Radium(SourceLink)
33 |
--------------------------------------------------------------------------------
/src/components/content/throws.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../../utils')
8 |
9 | const Throws = ({list, utils}) => {
10 | if (!list || !list.length) {
11 | return null
12 | }
13 |
14 | return (
15 |
16 |
Throws
17 | {list.map((ret, i) => (
18 |
19 |
20 | {ret.description ? (
21 |
25 | ) : null}
26 |
27 | ))}
28 |
29 | )
30 | }
31 |
32 | Throws.propTypes = {
33 | list: PropTypes.array,
34 | utils: PropTypes.instanceOf(Utils).isRequired
35 | }
36 |
37 | module.exports = Radium(Throws)
38 |
--------------------------------------------------------------------------------
/src/components/content/type.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const PropTypes = require('prop-types')
5 |
6 | const Utils = require('../../utils')
7 |
8 | const Type = ({name, val, defaultVal, utils}) => {
9 | let sig = `${name}: ${utils.formatType(val)}`
10 | if (defaultVal) {
11 | sig += ` (=${defaultVal})`
12 | }
13 |
14 | return (
15 |
16 | )
17 | }
18 |
19 | Type.propTypes = {
20 | name: PropTypes.string,
21 | val: PropTypes.any,
22 | defaultVal: PropTypes.string,
23 | utils: PropTypes.instanceOf(Utils).isRequired
24 | }
25 |
26 | module.exports = Type
27 |
--------------------------------------------------------------------------------
/src/components/header.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const {Container, Row, Column} = require('radium-bootstrap-grid')
6 | const Octocat = require('react-icons/lib/go/mark-github')
7 | const BookIcon = require('react-icons/lib/go/book')
8 |
9 | const {monoFont, sansSerifFont, lineHeight} = require('./styles')
10 |
11 | const Title = Radium(({value}) => {
12 | const style = {
13 | textTransform: 'uppercase',
14 | fontFamily: sansSerifFont
15 | }
16 |
17 | return (
18 |
19 | {value}
20 |
21 | )
22 | })
23 |
24 | const Version = Radium(({value}) => {
25 | const style = {
26 | fontFamily: monoFont,
27 | fontWeight: 300
28 | }
29 |
30 | return (
31 |
32 | {value}
33 |
34 | )
35 | })
36 |
37 | const Header = ({name, version, project}) => {
38 | const style = {
39 | boxShadow: '0px 2px 3px 0px rgba(0, 0, 0, 0.25)',
40 | height: lineHeight(2.5),
41 | width: '100%',
42 | minWidth: '100%',
43 | marginLeft: '0',
44 | marginRight: '0',
45 | position: 'fixed',
46 | zIndex: 99,
47 | background: '#FFFFFF',
48 | paddingTop: '10px',
49 | paddingBottom: '10px',
50 | paddingLeft: '20px',
51 | paddingRight: '20px'
52 | }
53 |
54 | let projectLink = null
55 |
56 | const projectLinkStyle = {
57 | textAlign: 'right',
58 | float: 'right !important',
59 | fontSize: '36px'
60 | }
61 |
62 | if (project) {
63 | projectLink = (
64 |
65 |
66 |
67 |
68 |
69 | )
70 | }
71 | const logoStyle = {
72 | fontSize: '36px',
73 | verticalAlign: 'inherit',
74 | marginRight: '20px'
75 | }
76 |
77 | const titleStyle = {
78 | display: 'inline-block'
79 | }
80 |
81 | return (
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 | {projectLink}
93 |
94 |
95 |
96 | )
97 | }
98 |
99 | module.exports = Radium(Header)
100 |
--------------------------------------------------------------------------------
/src/components/html.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const {Style} = require('radium')
5 |
6 | const {sansSerifFont, textColor, lineHeight} = require('./styles')
7 |
8 | const bodyStyle = {
9 | body: {
10 | margin: 0,
11 | padding: 0,
12 | color: textColor,
13 | fontFamily: sansSerifFont,
14 | fontWeight: 300,
15 | lineHeight: lineHeight(),
16 | fontSize: '17px'
17 | },
18 | '*': {
19 | boxSizing: 'border-box'
20 | }
21 | }
22 |
23 | module.exports = ({name, content}) => {
24 | return (
25 |
26 |
27 |
28 |
29 | {name} - Documentation
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 | )
38 | }
39 |
--------------------------------------------------------------------------------
/src/components/navigation.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const React = require('react')
4 | const Radium = require('radium')
5 | const PropTypes = require('prop-types')
6 |
7 | const Utils = require('../utils')
8 |
9 | const {
10 | lineHeight,
11 | sansSerifFont,
12 | textColor,
13 | lightGray
14 | } = require('./styles')
15 |
16 | const Member = Radium(({name, namespace, utils}) => {
17 | const linkStyle = {
18 | fontFamily: sansSerifFont,
19 | fontWeight: 300,
20 | fontSize: '13px',
21 | lineHeight: '16px',
22 | textDecoration: 'none',
23 | color: '#555'
24 | }
25 |
26 | return (
27 |
28 |
29 | {name}
30 |
31 |
32 | )
33 | })
34 |
35 | Member.propTypes = {
36 | name: PropTypes.string.isRequired,
37 | namespace: PropTypes.string,
38 | utils: PropTypes.instanceOf(Utils).isRequired
39 | }
40 |
41 | const Members = Radium(({items, name, first, utils}) => {
42 | const style = {
43 | paddingTop: first ? 0 : lineHeight(0.5)
44 | }
45 |
46 | const listStyle = {
47 | listStyle: 'none',
48 | paddingLeft: 0
49 | }
50 |
51 | const nameStyle = {
52 | textTransform: 'uppercase',
53 | fontSize: '13px',
54 | lineHeight: '18px',
55 | color: '#666'
56 | }
57 |
58 | return (
59 |
60 |
{name}
61 |
62 | {items.map((member, i) => (
63 |
68 | ))}
69 |
70 |
71 | )
72 | })
73 |
74 | Members.propTypes = {
75 | name: PropTypes.string,
76 | items: PropTypes.array,
77 | first: PropTypes.bool.isRequired,
78 | utils: PropTypes.instanceOf(Utils).isRequired
79 | }
80 |
81 | const Item = Radium(({name, members, last, namespace, utils}) => {
82 | let membersElements = []
83 |
84 | const isFirst = () => membersElements.length === 0
85 |
86 | if (members) {
87 | let keyCounter = 0
88 | if (members.static && members.static.length > 0) {
89 | membersElements.push(
90 |
96 | )
97 | }
98 |
99 | if (members.instance && members.instance.length > 0) {
100 | membersElements.push(
101 |
107 | )
108 | }
109 |
110 | if (members.events && members.events.length > 0) {
111 | membersElements.push(
112 |
118 | )
119 | }
120 | }
121 |
122 | const style = {
123 | paddingLeft: '20px',
124 | paddingRight: '20px',
125 | paddingTop: lineHeight(0.5),
126 | paddingBottom: lineHeight(0.5)
127 | }
128 |
129 | const itemStyle = {
130 | borderBottom: (last && !members) ? 'none' : `1px solid ${lightGray}`
131 | }
132 |
133 | const membersStyle = {
134 | borderBottom: (last && members) ? 'none' : `1px solid ${lightGray}`
135 |
136 | }
137 | return (
138 |
139 |
140 |
141 | {name}
142 |
143 |
144 | {members ? (
145 |
146 | {membersElements}
147 |
148 | ) : null}
149 |
150 | )
151 | })
152 |
153 | Item.propTypes = {
154 | name: PropTypes.string.isRequired,
155 | members: PropTypes.object,
156 | last: PropTypes.bool.isRequired,
157 | namespace: PropTypes.string,
158 | utils: PropTypes.instanceOf(Utils).isRequired
159 | }
160 |
161 | const Nav = ({items, utils}) => {
162 | const style = {
163 | borderRadius: '4px',
164 | border: `1px solid ${lightGray}`,
165 | paddingTop: 0,
166 | paddingBottom: 0,
167 | marginTop: lineHeight(),
168 | fontFamily: sansSerifFont,
169 | fontWeight: 500,
170 | fontSize: '15px',
171 | lineHeight: '18px',
172 | maxHeight: '70vh',
173 | overflowX: 'auto'
174 | }
175 |
176 | const listStyle = {
177 | listStyle: 'none',
178 | marginTop: 0,
179 | marginBottom: 0,
180 | paddingLeft: 0
181 | }
182 |
183 | return (
184 |
185 |
186 | {items.map((doc, i) => (
187 |
194 | ))}
195 |
196 |
197 | )
198 | }
199 |
200 | Nav.propTypes = {
201 | items: PropTypes.array,
202 | utils: PropTypes.instanceOf(Utils).isRequired
203 | }
204 |
205 | module.exports = Radium(Nav)
206 |
--------------------------------------------------------------------------------
/src/components/styles.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | exports.lineHeight = (n = 1) => `${n * 26}px`
4 |
5 | exports.monoFont = 'Roboto Mono, Menlo, Monaco, Courier, monospace'
6 | // exports.serifFont = 'Roboto Slab, serif'
7 | exports.sansSerifFont = 'Roboto, sans-serif'
8 |
9 | exports.textColor = '#000' // '#5b6888'
10 | exports.lightGray = '#e6e9ed'
11 |
12 | exports.contentStyles = {
13 | 'h1, h2, h3, h4, h5, h6': {
14 | fontFamily: exports.sansSerifFont,
15 | fontWeight: 300
16 | },
17 | h1: {
18 | fontSize: '48px',
19 | lineHeight: '72px'
20 | },
21 | h2: {
22 | fontSize: '24px',
23 | lineHeight: '36px'
24 | },
25 | h3: {
26 | fontSize: '19px',
27 | lineHeight: '29px',
28 | fontWeight: 400
29 | },
30 | h4: {
31 | fontSize: '17px',
32 | lineHeight: '22px',
33 | fontWeight: 400
34 | },
35 | a: {
36 | textDecoration: 'none',
37 | color: '#00AAFF',
38 | ':hover': {
39 | cursor: 'pointer'
40 | }
41 | },
42 | 'a.anchor:before': {
43 | content: '""',
44 | display: 'block',
45 | height: '100px',
46 | margin: '-80px 0 0'
47 | },
48 | '.content blockquote': {
49 | paddingLeft: '20px',
50 | margin: 0,
51 | borderLeft: '4px solid #eee'
52 | },
53 | '.content ul, content li': {
54 | listStyle: 'none'
55 | },
56 | '.content ul li:before': {
57 | color: '#CCC',
58 | float: 'left',
59 | marginLeft: '-20px',
60 | marginTop: '1px',
61 | content: '"•"'
62 | },
63 | 'pre.hljs, pre > code': {
64 | fontFamily: exports.monoFont,
65 | display: 'block',
66 | padding: '12px 15px 12px 15px',
67 | borderRadius: '4px',
68 | boxShadow: 'inset 0 0 0 1px rgba(0, 0, 0, 0.1)',
69 | marginBottom: '30px',
70 | position: 'relative',
71 | overflowX: 'auto',
72 | fontSize: '13px',
73 | color: '#666',
74 | whiteSpace: 'pre'
75 | },
76 | code: {
77 | fontFamily: exports.monoFont,
78 | display: 'inline',
79 | fontSize: '13px',
80 | fontWeight: 400,
81 | margin: '0 2px',
82 | padding: '1px 6px',
83 | boxShadow: '0 0 0 1px #DDD',
84 | whiteSpace: 'nowrap',
85 | borderRadius: '4px'
86 | },
87 | // Highlightjs Theme
88 | '.hljs': {
89 | display: 'block',
90 | overflowX: 'auto'
91 | },
92 | '.hljs-comment, .hljs-quote': {
93 | color: '#998',
94 | fontStyle: 'italic'
95 | },
96 | '.hljs-keyword, .hljs-selector-tag, .hljs-subst': {
97 | color: '#333',
98 | fontWeight: 'bold'
99 | },
100 | '.hljs-number, .hljs-literal, .hljs-variable, .hljs-template-variable, .hljs-tag .hljs-attr': {
101 | color: '#008080'
102 | },
103 | '.hljs-string, .hljs-doctag': {
104 | color: '#d14'
105 | },
106 | '.hljs-title, .hljs-section, .hljs-selector-id': {
107 | color: '#900',
108 | fontWeight: 'bold'
109 | },
110 | '.hljs-subst': {
111 | fontWeight: 'normal'
112 | },
113 | '.hljs-type, .hljs-class .hljs-title': {
114 | color: '#458',
115 | fontWeight: 'bold'
116 | },
117 | '.hljs-tag, .hljs-name, .hljs-attribute': {
118 | color: '#000080',
119 | fontWeight: 'normal'
120 | },
121 | '.hljs-regexp, .hljs-link': {
122 | color: '#009926'
123 | },
124 | '.hljs-symbol, .hljs-bullet': {
125 | color: '#990073'
126 | },
127 | '.hljs-built_in, .hljs-builtin-name': {
128 | color: '#0086b3'
129 | },
130 | '.hljs-meta': {
131 | color: '#999',
132 | fontWeight: 'bold'
133 | },
134 | '.hljs-deletion': {
135 | background: '#fdd'
136 | },
137 | '.hljs-addition': {
138 | background: '#dfd'
139 | },
140 | '.hljs-emphasis': {
141 | fontStyle: 'italic'
142 | },
143 | '.hljs-strong': {
144 | fontWeight: 'bold'
145 | }
146 | }
147 |
--------------------------------------------------------------------------------
/src/index.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const path = require('path')
4 | const File = require('vinyl')
5 | const vfs = require('vinyl-fs')
6 | const concat = require('concat-stream')
7 | const render = require('react-dom/server').renderToStaticMarkup
8 | const React = require('react')
9 |
10 | const Html = React.createFactory(require('./components/html.js'))
11 | const App = React.createFactory(require('./components/app.js'))
12 |
13 | function pageTemplate (props) {
14 | const content = render(new App(props))
15 | const markup = new Html({
16 | name: props.options.name,
17 | content: content
18 | })
19 |
20 | const html = render(markup)
21 |
22 | return `\n${html}`
23 | }
24 |
25 | module.exports = function (comments, options) {
26 | return new Promise((resolve) => {
27 | options.name = options['project-name']
28 | options.version = options['project-version']
29 | options.project = options['project-homepage']
30 |
31 | // push assets into the pipeline as well.
32 | vfs.src([path.join(__dirname, '/assets/**')], { base: __dirname }).pipe(
33 | concat((files) => {
34 | resolve(files.concat(new File({
35 | path: 'index.html',
36 | contents: Buffer.from(pageTemplate({
37 | docs: comments,
38 | options: options
39 | }), 'utf8')
40 | })))
41 | }))
42 | })
43 | }
44 |
--------------------------------------------------------------------------------
/src/utils.js:
--------------------------------------------------------------------------------
1 | 'use strict'
2 |
3 | const GithubSlugger = require('github-slugger')
4 | const hljs = require('highlight.js')
5 | const util = require('documentation').util
6 | const createFormatters = util.createFormatters
7 | const LinkerStack = util.LinkerStack
8 | const _ = require('lodash')
9 |
10 | module.exports = class Utils {
11 | constructor (options, comments) {
12 | this.linkerStack = new LinkerStack(options)
13 | .namespaceResolver(comments, (namespace) => {
14 | const slugger = new GithubSlugger()
15 | return '#' + slugger.slug(namespace)
16 | })
17 |
18 | this.options = options
19 | this.comments = comments
20 | this.formatters = createFormatters(this.linkerStack.link)
21 | this.options.hljs = this.options.hljs || {}
22 |
23 | hljs.configure(this.options.hljs)
24 |
25 | this.formatType = this.formatters.type
26 | this.autolink = this.formatters.autolink
27 | }
28 |
29 | md (ast, inline) {
30 | if (inline && ast && ast.children.length && ast.children[0].type === 'paragraph') {
31 | ast = {
32 | type: 'root',
33 | children: ast.children[0].children.concat(ast.children.slice(1))
34 | }
35 | }
36 | return this.formatters.markdown(ast)
37 | }
38 |
39 | highlight (code) {
40 | if (this.options.hljs && this.options.hljs.highlightAuto) {
41 | return hljs.highlightAuto(code).value
42 | }
43 | return hljs.highlight('js', code).value
44 | }
45 |
46 | signature (section) {
47 | let returns = ''
48 | let prefix = ''
49 |
50 | if (section.kind === 'class') {
51 | prefix = 'new '
52 | } else if (section.kind !== 'function') {
53 | const type = getType(section)
54 | if (type) {
55 | return `${section.name}: ${this.formatType(type)}`
56 | }
57 |
58 | return section.name
59 | }
60 |
61 | if (section.returns && section.returns.length > 0) {
62 | returns = `: ${this.formatType(section.returns[0].type)}`
63 | }
64 |
65 | return prefix + section.name + this.formatters.parameters(section) + returns
66 | }
67 |
68 | slug (str) {
69 | const slugger = new GithubSlugger()
70 | return slugger.slug(str)
71 | }
72 | }
73 |
74 | function getType (section) {
75 | if (!section.tags) {
76 | return
77 | }
78 |
79 | const tag = _.find(section.tags, (tag) => tag.title === 'type')
80 |
81 | if (!tag) {
82 | return
83 | }
84 |
85 | return tag.type
86 | }
87 |
--------------------------------------------------------------------------------
/test/components/app-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const React = require('react')
5 | const expect = require('chai').expect
6 | const {render} = require('enzyme')
7 |
8 | const App = require('../../lib/components/app')
9 |
10 | describe('', () => {
11 | it('renders', () => {
12 | expect(
13 | render().children()
14 | ).to.have.length(1)
15 | })
16 | })
17 |
--------------------------------------------------------------------------------
/test/components/extends-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const React = require('react')
5 | const expect = require('chai').expect
6 | const {render} = require('enzyme')
7 |
8 | const Extends = require('../../lib/components/content/extends')
9 | const Utils = require('../../lib/utils')
10 |
11 | describe('', () => {
12 | const utils = new Utils({}, [])
13 |
14 | it('renders', () => {
15 | const list = [{
16 | name: 'Foo'
17 | }, {
18 | name: 'Bar'
19 | }]
20 | const res = render(
21 |
22 | )
23 |
24 | expect(res.text()).to.be.eql(' Extends Foo, Bar.')
25 | })
26 |
27 | it('renders nothing if list is missing', () => {
28 | expect(
29 | render().html()
30 | ).to.be.eql('')
31 | })
32 | })
33 |
--------------------------------------------------------------------------------
/test/components/index.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | require('babel-register')
5 |
6 | describe('Components', () => {
7 | require('./app-test')
8 | require('./source-link-test')
9 | require('./returns-test')
10 | require('./throws-test')
11 | require('./extends-test')
12 | require('./see-test')
13 | })
14 |
--------------------------------------------------------------------------------
/test/components/returns-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const React = require('react')
5 | const expect = require('chai').expect
6 | const {render} = require('enzyme')
7 | const remark = require('remark')
8 |
9 | const Returns = require('../../lib/components/content/returns')
10 | const Utils = require('../../lib/utils')
11 |
12 | describe('', () => {
13 | const utils = new Utils({}, [])
14 |
15 | it('renders', () => {
16 | const returns = [{
17 | type: {
18 | type: 'NameExpression',
19 | name: 'Foo'
20 | },
21 | description: remark().parse('cool foo result')
22 | }]
23 | const res = render(
24 |
25 | )
26 |
27 | expect(res.find('h4').text()).to.be.eql('Returns')
28 | const code = res.find('code')
29 | expect(code).to.have.length(1)
30 | expect(code.text()).to.be.eql('Foo')
31 |
32 | const description = res.find('span')
33 | expect(description).to.have.length(1)
34 | expect(description.text()).to.be.eql(' cool foo result\n')
35 | })
36 |
37 | it('renders nothing if list is missing', () => {
38 | expect(
39 | render().html()
40 | ).to.be.eql('')
41 | })
42 | })
43 |
--------------------------------------------------------------------------------
/test/components/see-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const React = require('react')
5 | const expect = require('chai').expect
6 | const {render} = require('enzyme')
7 |
8 | const See = require('../../lib/components/content/see')
9 | const Utils = require('../../lib/utils')
10 |
11 | describe('', () => {
12 | const utils = new Utils({}, [])
13 |
14 | it('renders', () => {
15 | const list = [{
16 | title: 'see',
17 | description: '[link](github.com)'
18 | }, {
19 | title: 'other'
20 | }, {
21 | title: 'see',
22 | description: 'other things'
23 | }]
24 | const res = render(
25 |
26 | )
27 |
28 | expect(res.find('h4').text()).to.be.eql('See')
29 |
30 | const lis = res.find('li')
31 | expect(lis).to.have.length(2)
32 |
33 | const links = res.find('li a')
34 | expect(links).to.have.length(1)
35 | expect(links.attr('href')).to.be.eql('github.com')
36 | expect(links.text()).to.be.eql('link')
37 |
38 | expect(lis.last().text()).to.be.eql('other things\n')
39 | })
40 |
41 | it('renders nothing if list is missing', () => {
42 | expect(
43 | render().html()
44 | ).to.be.eql('')
45 | })
46 | })
47 |
--------------------------------------------------------------------------------
/test/components/source-link-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const React = require('react')
5 | const expect = require('chai').expect
6 | const {render} = require('enzyme')
7 |
8 | const SourceLink = require('../../lib/components/content/source-link')
9 |
10 | describe('', () => {
11 | it('renders', () => {
12 | const context = {
13 | github: {
14 | url: 'github.com/source.js',
15 | path: 'source.js'
16 | }
17 | }
18 | const link = render(
19 |
20 | ).find('a')
21 |
22 | expect(link.attr('href')).to.be.eql(context.github.url)
23 | expect(link.attr('title')).to.be.eql(context.github.path)
24 | })
25 |
26 | it('renders nothing if context is missing', () => {
27 | expect(
28 | render().html()
29 | ).to.be.eql('')
30 | })
31 | })
32 |
--------------------------------------------------------------------------------
/test/components/throws-test.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const React = require('react')
5 | const expect = require('chai').expect
6 | const {render} = require('enzyme')
7 | const remark = require('remark')
8 |
9 | const Throws = require('../../lib/components/content/throws')
10 | const Utils = require('../../lib/utils')
11 |
12 | describe('', () => {
13 | const utils = new Utils({}, [])
14 |
15 | it('renders', () => {
16 | const throws = [{
17 | type: {
18 | type: 'NameExpression',
19 | name: 'Error'
20 | },
21 | description: remark().parse('bad error')
22 | }]
23 | const res = render(
24 |
25 | )
26 |
27 | expect(res.find('h4').text()).to.be.eql('Throws')
28 | const code = res.find('code')
29 | expect(code).to.have.length(1)
30 | expect(code.text()).to.be.eql('Error')
31 |
32 | const description = res.find('span')
33 | expect(description).to.have.length(1)
34 | expect(description.text()).to.be.eql(' bad error\n')
35 | })
36 |
37 | it('renders nothing if list is missing', () => {
38 | expect(
39 | render().html()
40 | ).to.be.eql('')
41 | })
42 | })
43 |
--------------------------------------------------------------------------------
/test/utils.spec.js:
--------------------------------------------------------------------------------
1 | /* eslint-env mocha */
2 | 'use strict'
3 |
4 | const Syntax = require('doctrine').Syntax
5 | const expect = require('chai').expect
6 | const remark = require('remark')
7 |
8 | const Utils = require('../lib/utils')
9 |
10 | describe('utils', () => {
11 | const u = new Utils({hljs: {highlightAuto: false}}, [])
12 |
13 | describe('md', () => {
14 | it('renders remark asts', () => {
15 | expect(
16 | u.md(
17 | remark().parse(
18 | 'Converts from `Result` to `?Error`'
19 | )
20 | )
21 | ).to.be.eql(
22 | 'Converts from Result
to ?Error
\n'
23 | )
24 | })
25 | })
26 |
27 | it('.formatType', () => {
28 | const formatType = u.formatType
29 |
30 | expect(formatType(undefined)).to.be.eql('any')
31 |
32 | expect(formatType({
33 | type: 'NameExpression',
34 | name: 'Foo'
35 | })).to.be.eql('Foo')
36 |
37 | expect(formatType({
38 | type: 'NameExpression',
39 | name: 'Buffer'
40 | })).to.be.eql('Buffer')
41 | })
42 |
43 | it('.highlight', () => {
44 | expect(
45 | u.highlight('var text = "hello"')
46 | ).to.be.eql(
47 | 'var text = "hello"'
48 | )
49 | })
50 |
51 | it('signature', () => {
52 | expect(
53 | u.signature({
54 | kind: 'class',
55 | name: 'Test',
56 | params: [{
57 | name: 'a',
58 | type: {type: Syntax.NumericLiteralType, value: 'number'}
59 | }]
60 | })
61 | ).to.be.eql(
62 | 'new Test(a: number
)'
63 | )
64 |
65 | expect(
66 | u.signature({
67 | kind: 'function',
68 | name: 'test',
69 | params: [{
70 | name: 'a',
71 | type: {type: Syntax.NumericLiteralType, value: 'number'}
72 | }],
73 | returns: [{
74 | type: {type: Syntax.NumericLiteralType, value: 'number'}
75 | }]
76 | })
77 | ).to.be.eql(
78 | 'test(a: number
): number
'
79 | )
80 |
81 | expect(
82 | u.signature({
83 | kind: 'property',
84 | name: 'test',
85 | tags: [{
86 | title: 'type',
87 | type: {type: Syntax.NumericLiteralType, value: 'number'}
88 | }]
89 | })
90 | ).to.be.eql(
91 | 'test: number
'
92 | )
93 | })
94 | })
95 |
--------------------------------------------------------------------------------