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

Discussion: Remove markdown parsing from dox? #159

Open
Twipped opened this issue Mar 18, 2015 · 10 comments
Open

Discussion: Remove markdown parsing from dox? #159

Twipped opened this issue Mar 18, 2015 · 10 comments

Comments

@Twipped
Copy link
Collaborator

Twipped commented Mar 18, 2015

This issue is for discussion of possibly changing dox to use CommonMark standard markdown parsing, via the commonmark npm package removing markdown parsing from the main library, possibly making it an example or extension module.

The first opportunity to make this change would be for a 1.0 release. I welcome comments either for or against this change. I'll be leaving this open until I hear some feedback or have reached a point that I feel dox is ready for 1.0.

@Twipped
Copy link
Collaborator Author

Twipped commented Mar 18, 2015

Another possibility might be simply removing markdown entirely. Split the command line tool out as a separate package and refocus dox as just a jsdoc parser. Let implementers choose their own markdown engine.

@tmcw
Copy link

tmcw commented Mar 18, 2015

I'd definitely support splitting it out. For documentation we're trying to keep markdown & html as separate concerns to parsing jsdoc & inferring from code.

@puzrin
Copy link

puzrin commented Mar 23, 2015

https://github.com/markdown-it/markdown-it that's an alternative CM parser.

@trusktr
Copy link
Contributor

trusktr commented Mar 23, 2015

👍 to the ability to choose which markdown parser is used.

What about if dox uses some parser by default like commonmark or markdown-it, but make it easy to specify a markdown parser, f.e.

// ...

var someAwesomeMarkdownParser = require('awesome-markdown-parser');

// set the markdown parser that dox will be using anytime parseComments is called
dox.markdownParser(function(input) {
  // assuming someAwesomeMarkdownParser is synchronous:
  return someAwesomeMarkdownParser(input);
});

dox.parseComments(someCode, options);

@Twipped
Copy link
Collaborator Author

Twipped commented Mar 23, 2015

Technically there's nothing preventing anyone from using their own parser today. Just pass in raw:true and run the output yourself (that's how I do it on my own doc sites).

That said, it'd be trivial to take a callback option to use for conversion.

On Mar 22, 2015, at 8:46 PM, Joseph Orbegoso Pea [email protected] wrote:

to the ability to choose which markdown parser is used.

What about if dox uses some parser by default like commonmark or markdown-it, but make it easy to specify a markdown parser, f.e.

// ...

var someAwesomeMarkdownParser = require('awesome-markdown-parser');

// set the markdown parser that dox will be using anytime parseComments is called
dox.markdownParser(function(input) {
// assuming someAwesomeMarkdownParser is synchronous:
return someAwesomeMarkdownParser(input);
});

dox.parseComments(someCode, options);

Reply to this email directly or view it on GitHub.

@tomek-he-him
Copy link
Contributor

For documentation we're trying to keep markdown & html as separate concerns to parsing jsdoc & inferring from code.

...

Just pass in raw:true and run the output yourself (that's how I do it on my own doc sites)

I do so too. Perhaps even most of us do?

To be honest, parsing markdown has seemed a cross-cutting concern to me – from the very beginning I started using dox.

@trusktr
Copy link
Contributor

trusktr commented Mar 23, 2015

I'm think removing it from dox itself would be best.

Then, generally speaking, dox could be made pluggable and features could be added via plugin modules, and users could do something like

// ...
var dox = require('dox')
var doxMarkdownIt = require('dox-markdown-it')
var someOtherPluginForDox = require('dox-blahblah')

dox.use(doxMarkdownIt)
dox.use(someOtherPluginForDox)

var comments = dox.parseComments(code, options)

then that might be a nice pattern. Maybe we can get inspiration from jsstyles/jss, which is where I saw that pattern. JSS has a bunch of plugins.

@tomek-he-him
Copy link
Contributor

dox could be made pluggable and features could be added via plugin modules

Great idea! Perhaps even:

var comments = dox.parseComments(code, options)
  .use(doxMarkdownIt())
  .use(someOtherPluginForDox({unicorns: true}))
  ;

var otherComments = dox.parseComments(otherCode, options)
  .use(doxMarkdownIt())
  ;

@Twipped Twipped changed the title Discussion: Switch from marked to commonmark for markdown parsing Discussion: Remove markdown parsing from dox? Mar 24, 2015
@Twipped
Copy link
Collaborator Author

Twipped commented Mar 24, 2015

Changing the title of this, since it sounds like people are leaning more in that direction. At this point I'm pretty persuaded in favor of it. Now that 0.7 is out the door I'm tentatively planning to deprecate markdown in 0.8 and formally remove it in 1.0.

I don't think a plugin architecture is a good solution, it would just make the library more complicated when it's already more complex than it should be. I do think that more of dox can be refactored into overridable functions, which would accomplish the same goal.

@trusktr
Copy link
Contributor

trusktr commented Mar 25, 2015

I do think that more of dox can be refactored into overridable functions, which would accomplish the same goal.

Sounds good to me!

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

No branches or pull requests

5 participants