@@ -20,53 +20,52 @@ var slugify = require('slugify');
2020
2121var styleReferencePattern = / ^ [ ^ . ] + \. p r o p T y p e s \. s t y l e $ / ;
2222
23- var ComponentDoc = React . createClass ( {
24- renderType : function ( type ) {
25- if ( type . name === 'enum' ) {
26- if ( typeof type . value === 'string' ) {
27- return type . value ;
28- }
29- return 'enum(' + type . value . map ( ( v => v . value ) ) . join ( ', ' ) + ')' ;
23+ function renderType ( type ) {
24+ if ( type . name === 'enum' ) {
25+ if ( typeof type . value === 'string' ) {
26+ return type . value ;
3027 }
28+ return 'enum(' + type . value . map ( ( v ) => v . value ) . join ( ', ' ) + ')' ;
29+ }
3130
32- if ( type . name === 'shape' ) {
33- return '{' + Object . keys ( type . value ) . map ( ( key => key + ': ' + this . renderType ( type . value [ key ] ) ) ) . join ( ', ' ) + '}' ;
34- }
31+ if ( type . name === 'shape' ) {
32+ return '{' + Object . keys ( type . value ) . map ( ( key => key + ': ' + renderType ( type . value [ key ] ) ) ) . join ( ', ' ) + '}' ;
33+ }
3534
36- if ( type . name == 'union' ) {
37- return type . value . map ( this . renderType ) . join ( ', ' ) ;
38- }
35+ if ( type . name == 'union' ) {
36+ return type . value . map ( renderType ) . join ( ', ' ) ;
37+ }
3938
40- if ( type . name === 'arrayOf' ) {
41- return '[' + this . renderType ( type . value ) + ']' ;
42- }
39+ if ( type . name === 'arrayOf' ) {
40+ return '[' + renderType ( type . value ) + ']' ;
41+ }
4342
44- if ( type . name === 'instanceOf' ) {
45- return type . value ;
46- }
43+ if ( type . name === 'instanceOf' ) {
44+ return type . value ;
45+ }
4746
48- if ( type . name === 'custom' ) {
49- if ( styleReferencePattern . test ( type . raw ) ) {
50- var name = type . raw . substring ( 0 , type . raw . indexOf ( '.' ) ) ;
51- return < a href = { slugify ( name ) + '.html#style' } > { name } #style</ a >
52- }
53- if ( type . raw === 'EdgeInsetsPropType' ) {
54- return '{top: number, left: number, bottom: number, right: number}' ;
55- }
56- return type . raw ;
47+ if ( type . name === 'custom' ) {
48+ if ( styleReferencePattern . test ( type . raw ) ) {
49+ var name = type . raw . substring ( 0 , type . raw . indexOf ( '.' ) ) ;
50+ return < a href = { slugify ( name ) + '.html#style' } > { name } #style</ a >
5751 }
58-
59- if ( type . name === 'stylesheet' ) {
60- return 'style' ;
52+ if ( type . raw === 'EdgeInsetsPropType' ) {
53+ return '{top: number, left: number, bottom: number, right: number}' ;
6154 }
55+ return type . raw ;
56+ }
6257
63- if ( type . name === 'func ' ) {
64- return 'function ' ;
65- }
58+ if ( type . name === 'stylesheet ' ) {
59+ return 'style ' ;
60+ }
6661
67- return type . name ;
68- } ,
62+ if ( type . name === 'func' ) {
63+ return 'function' ;
64+ }
65+ return type . name ;
66+ }
6967
68+ var ComponentDoc = React . createClass ( {
7069 renderProp : function ( name , prop ) {
7170 return (
7271 < div className = "prop" key = { name } >
@@ -77,7 +76,7 @@ var ComponentDoc = React.createClass({
7776 { name }
7877 { ' ' }
7978 { prop . type && < span className = "propType" >
80- { this . renderType ( prop . type ) }
79+ { renderType ( prop . type ) }
8180 </ span > }
8281 </ Header >
8382 { prop . type && prop . type . name === 'stylesheet' &&
@@ -128,7 +127,7 @@ var ComponentDoc = React.createClass({
128127 { name }
129128 { ' ' }
130129 { style . props [ name ] . type && < span className = "propType" >
131- { this . renderType ( style . props [ name ] . type ) }
130+ { renderType ( style . props [ name ] . type ) }
132131 </ span > }
133132 </ h6 >
134133 </ div >
@@ -190,7 +189,6 @@ var ComponentDoc = React.createClass({
190189 < Marked >
191190 { content . description }
192191 </ Marked >
193-
194192 < HeaderWithGithub
195193 title = "Props"
196194 path = { content . filepath }
@@ -264,7 +262,6 @@ var APIDoc = React.createClass({
264262 ) ;
265263 } ,
266264
267-
268265 renderMethods : function ( methods ) {
269266 if ( ! methods . length ) {
270267 return null ;
@@ -281,6 +278,67 @@ var APIDoc = React.createClass({
281278 ) ;
282279 } ,
283280
281+ renderProperty : function ( property ) {
282+ return (
283+ < div className = "prop" key = { property . name } >
284+ < Header level = { 4 } className = "propTitle" toSlug = { property . name } >
285+ { property . name }
286+ { property . type &&
287+ < span className = "propType" >
288+ { ': ' + renderType ( property . type ) }
289+ </ span >
290+ }
291+ </ Header >
292+ { property . docblock && < Marked >
293+ { this . removeCommentsFromDocblock ( property . docblock ) }
294+ </ Marked > }
295+ </ div >
296+ ) ;
297+ } ,
298+
299+ renderProperties : function ( properties ) {
300+ if ( ! properties || ! properties . length ) {
301+ return null ;
302+ }
303+ return (
304+ < span >
305+ < H level = { 3 } > Properties</ H >
306+ < div className = "props" >
307+ { properties . filter ( ( property ) => {
308+ return property . name [ 0 ] !== '_' ;
309+ } ) . map ( this . renderProperty ) }
310+ </ div >
311+ </ span >
312+ ) ;
313+ } ,
314+
315+ renderClasses : function ( classes ) {
316+ if ( ! classes || ! classes . length ) {
317+ return null ;
318+ }
319+ return (
320+ < span >
321+ < div >
322+ { classes . filter ( ( cls ) => {
323+ return cls . name [ 0 ] !== '_' && cls . ownerProperty [ 0 ] !== '_' ;
324+ } ) . map ( ( cls ) => {
325+ return (
326+ < span key = { cls . name } >
327+ < Header level = { 2 } toSlug = { cls . name } >
328+ class { cls . name }
329+ </ Header >
330+ < ul >
331+ { this . renderMethods ( cls . methods ) }
332+ { this . renderProperties ( cls . properties ) }
333+ </ ul >
334+ </ span >
335+ ) ;
336+ } ) }
337+ </ div >
338+ </ span >
339+ ) ;
340+ } ,
341+
284342 render : function ( ) {
285343 var content = this . props . content ;
286344 if ( ! content . methods ) {
@@ -294,6 +352,8 @@ var APIDoc = React.createClass({
294352 { this . removeCommentsFromDocblock ( content . docblock ) }
295353 </ Marked >
296354 { this . renderMethods ( content . methods ) }
355+ { this . renderProperties ( content . properties ) }
356+ { this . renderClasses ( content . classes ) }
297357 </ div >
298358 ) ;
299359 }
@@ -371,7 +431,7 @@ var Autodocs = React.createClass({
371431 var docs = JSON . parse ( this . props . children ) ;
372432 var content = docs . type === 'component' || docs . type === 'style' ?
373433 < ComponentDoc content = { docs } /> :
374- < APIDoc content = { docs } /> ;
434+ < APIDoc content = { docs } apiName = { metadata . title } /> ;
375435
376436 return (
377437 < Site section = "docs" title = { metadata . title } >
0 commit comments