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

Templates should define "exports.publish" instead of a global "publish" function #166

Closed
wants to merge 4 commits into from
Closed

Conversation

hegemonic
Copy link
Contributor

JSDoc expects templates to define a global publish function that publishes the docs. This works fine, but it effectively precludes the following enhancements, all of which I'd love to implement at some point:

  • Create a template that can be subclassed, so child templates can inherit some template functions but override others.
  • Generate output for multiple templates simultaneously.
  • Create a web server that generates individual doc pages on demand, allowing users to switch templates on the fly. (This will be much easier to implement once JSDoc can run on Node.js.)

To add flexibility, I think it would be better for templates to assign the publish function to exports.publish.

This pull request adds support for this feature and converts the existing templates to use exports.publish instead of publish. It doesn't remove support for the global publish function, so existing user-defined templates will still work; however, it logs a warning if a template relies upon a global publish function.

The diffs for the templates' publish.js files are misleadingly large. Most of the changes are just whitespace adjustments. I also made a few other changes to address JSHint warnings. I tested the templates by running them against JSDoc, and everything appears to be working as expected.

(The pull request also fixes an unrelated issue with the jsdoc shell script's --debug option, which wasn't being stripped properly, at least on OS X. I ran into this while I was debugging the other changes.)

I'll wait to merge this until I get some feedback on whether these changes make sense.

@hegemonic
Copy link
Contributor Author

Well, drat, this still can't be merged automatically. I'd be happy to take care of the merge.

@hegemonic
Copy link
Contributor Author

Contrary to what I said above, I'll merge this on Thursday or Friday unless I hear an objection before then, so I can start tackling other template bugs without creating merge conflicts.

@micmath
Copy link
Contributor

micmath commented Aug 21, 2012

Thanks @hegemonic No objections from me!

@hegemonic
Copy link
Contributor Author

Great, thanks! I'll email the mailing list so template authors aren't caught off guard by this change.

@hegemonic hegemonic closed this Aug 22, 2012
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

Successfully merging this pull request may close these issues.

None yet

2 participants