File tree Expand file tree Collapse file tree 4 files changed +90
-6
lines changed
fixtures/missing-pages-dir/src Expand file tree Collapse file tree 4 files changed +90
-6
lines changed Original file line number Diff line number Diff line change @@ -119,12 +119,15 @@ export default class Extracter {
119119 extractPages ( ) : Dictionary < string > {
120120 let dir = this . pagesDir ;
121121 debug ( `Extracting pages for ${ this . dir } from ${ dir } ` ) ;
122- let files = walk ( dir , { directories : false } ) ;
123- return files . reduce ( ( pages : Dictionary < string > , file : string ) => {
124- debug ( `Found a page: ${ file } ` ) ;
125- pages [ file ] = read ( path . join ( dir , file ) , 'utf-8' ) ;
126- return pages ;
127- } , < Dictionary < string > > { } ) ;
122+ if ( exists ( dir ) ) {
123+ let files = walk ( dir , { directories : false } ) ;
124+ return files . reduce ( ( pages : Dictionary < string > , file : string ) => {
125+ debug ( `Found a page: ${ file } ` ) ;
126+ pages [ file ] = read ( path . join ( dir , file ) , 'utf-8' ) ;
127+ return pages ;
128+ } , < Dictionary < string > > { } ) ;
129+ }
130+ return { } ;
128131 }
129132
130133 extractApi ( ) : API {
Original file line number Diff line number Diff line change 1+ import test from 'ava' ;
2+ import * as path from 'path' ;
3+ import { Extracter } from '../dist/index' ;
4+ import output from './helpers/output-expectation' ;
5+
6+ test ( 'allow non-existent pages directory' , async ( t ) => {
7+ let extracter = new Extracter ( {
8+ dir : path . join ( __dirname , 'fixtures' , 'missing-pages-dir' ) ,
9+ pagesDir : 'guides' ,
10+ sourceDirs : [ 'src' ] ,
11+ projectName : 'javascript-project' ,
12+ projectVersion : '1.0.0'
13+ } ) ;
14+ let result = extracter . extract ( ) ;
15+ t . deepEqual ( result , Object . assign ( output ( 'js' ) , { pages : { } } ) ) ;
16+ } ) ;
Original file line number Diff line number Diff line change 1+ /**
2+ * He's such a good boi!
3+ *
4+ * No srsly. such good
5+ *
6+ * @class Dog
7+ * @constructor
8+ */
9+ export default class Dog {
10+
11+ /**
12+ * What's the dog's current mood?
13+ *
14+ * @property mood
15+ * @type string
16+ */
17+ mood = 'happy' ;
18+
19+ /**
20+ * Make some noise
21+ *
22+ * @method bark
23+ * @param volume {number} How loud?
24+ * @public
25+ * @foo bar
26+ */
27+ bark ( volume ) {
28+
29+ }
30+
31+ /**
32+ * Checks if this.goodBoi is true, and if so, requests a belly rub.
33+ * Returns true if belly rub was successful.
34+ *
35+ * @method requestBellyRub
36+ * @returns {boolean } Was the belly rub successful?
37+ * @protected
38+ */
39+ requestBellyRub ( ) {
40+
41+ }
42+
43+ // Custom tags, private
44+ /**
45+ * Digs a hole in blankets or dirt
46+ *
47+ * @method burrow
48+ * @isGoodBoi true
49+ * @private
50+ */
51+ burrow ( ) {
52+
53+ }
54+
55+ }
Original file line number Diff line number Diff line change 1+ // Free function
2+ /**
3+ * Pet the good boi!
4+ *
5+ * @method pet
6+ * @public
7+ */
8+ export function pet ( ) {
9+
10+ }
You can’t perform that action at this time.
0 commit comments