Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No "script.js" for JavaScript @example #104

Open
jredh opened this issue Jun 30, 2016 · 2 comments
Open

No "script.js" for JavaScript @example #104

jredh opened this issue Jun 30, 2016 · 2 comments

Comments

@jredh
Copy link

jredh commented Jun 30, 2016

I've been trying to create an example like:

/**
* @ngdoc service
* @name example
* @description
* # This does stuff
* @example
    <example module="myApp">
        <file name="script.js">
              console.log('This should execute');
        </file>
    </example>
*/
angular.module( 'myApp', [] )
    .factory( 'example', function ( $log ) {
        ... 
    } );

Gives me the following error:

E:\development\js\proj\node_modules\gulp-ngdocs\src\example.js:142
  out.push(' ng-set-html="' + this.html[0].id + '"');

TypeError: Cannot read property 'id' of undefined at exports.Example.toHtmlEmbed (E:\development\js\proj\node_modules\gulp-ngdocs\src\example.js:142:43)
    at exports.Example.toHtml (E:\development\js\proj\node_modules\gulp-ngdocs\src\example.js:80:16)
    at E:\development\js\proj\node_modules\gulp-ngdocs\src\ngdoc.js:220:38
    at String.replace (native)
    at E:\development\js\proj\node_modules\gulp-ngdocs\src\ngdoc.js:193:9
    at Array.forEach (native)
    at Object.Doc.markdown (E:\development\js\proj\node_modules\gulp-ngdocs\src\ngdoc.js:191:11)
    at Object.Doc.parse (E:\development\js\proj\node_modules\gulp-ngdocs\src\ngdoc.js:401:25)
    at E:\development\js\proj\node_modules\gulp-ngdocs\src\reader.js:49:99
    at Array.forEach (native)
    at processJsFile (E:\development\js\proj\node_modules\gulp-ngdocs\src\reader.js:34:9)
    at Object.process (E:\development\js\proj\node_modules\gulp-ngdocs\src\reader.js:17:5)
    at DestroyableTransform.transformFunction [as _transform] (E:\development\js\proj\node_modules\gulp-ngdocs\index.js:204:14)
    at DestroyableTransform.Transform._read (E:\development\js\proj\node_modules\gulp-ngdocs\node_modules\readable-stream\lib\_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (E:\development\js\proj\node_modules\gulp-ngdocs\node_modules\readable-stream\lib\_stream_transform.js:172:12)
    at doWrite (E:\development\js\proj\node_modules\gulp-ngdocs\node_modules\readable-stream\lib\_stream_writable.js:237:10)

I've seen this done in Angular's documentation. However, the package works with...

@example
<example module="myApp">
<file name="index.html">
   <div ng-repeat="i in [1,2,3] | oddFilter">
        {{ i }}
    </div>
</file>
</example>

But not with the script.js to document a JavaScript example.

Please advise on how I can work around this.

@paul-barry-kenzan
Copy link

@hooph00p
I'm experiencing this exact issue. Example works for name="index.html, however, when renaming to name="config.js" I get the same error.

../node_modules/gulp-ngdocs/src/example.js:142
  out.push(' ng-set-html="' + this.html[0].id + '"');
                                          ^

TypeError: Cannot read property 'id' of undefined

@gseabrook
Copy link

The problem is that you need to have a file element with a name of *.html, otherwise this.html is empty and you see the error above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants