jsdoc2md / dmd

The default output template for jsdoc2md
MIT License
39 stars 50 forks source link

Support Gitiles markdown rendering #60

Closed Krinkle closed 5 years ago

Krinkle commented 5 years ago

Thanks for making jsdoc-to-markdown. I love this library and it's amazing.

At Wikimedia Foundation, we host most source code repositories with Gerrit; using Gitiles as repository viewer (from Google; used for android, chromium, etc.; googlesource.com example, wikimedia.org example).

Unfortunately, Gitiles does not support the <dl> HTML extension to markdown. The result is that API.md (source) renders as API.md (gitiles) with much of the content missing:

Okay (md-fileserver) Broken (Gitiles)
rendered by md-fileserver rendered by Gitiles

I'm looking to bypass this problem with a set of custom partials, but I'm not sure where to begin and how much I'd have to override. Perhaps this could be part of jsdoc2md, e.g. via a preset of some kind. Would you accept a pull request to that end?

The resulting visual rendering might be less pleasing than the indentation of dictionary lists (which I quite like actually), but it would allow for wider compatibility.

(Upstream bug report: https://github.com/google/gitiles/issues/81)

75lb commented 5 years ago

Hi mate, sorry for the slow reply. You should be able achieve the output you need by passing in your own custom partials or plugin.

Start by overriding the module-index partial adding your own command-line arg value, e.g.

{{#if (optionEquals "module-index-format" "krinkle")}}{{>module-index-krinkle ~}}{{/if~}}

Next, you'll need to create the partial file module-index-krinkle.hbs (which contains your desired index template) and pass it in with your jsdoc2md command, e.g.

$ jsdoc2md --module-index-format krinkle --partial module-index.hbs module-index-krinkle.hbs --files lib/*

For example, if using the example partials and source files here, the above command would output:

{ id: 'module:something',
  longname: 'module:something',
  name: 'something',
  kind: 'module',
  thisvalue: undefined,
  meta:
   { lineno: 1,
     filename: 'modulea.js',
     path: '/Users/llobrook/Documents/75lb/tmp/jdsoc2md/lib' },
  order: 0 }
{ id: 'module:anotherthing',
  longname: 'module:anotherthing',
  name: 'anotherthing',
  kind: 'module',
  thisvalue: undefined,
  meta:
   { lineno: 1,
     filename: 'moduleb.js',
     path: '/Users/llobrook/Documents/75lb/tmp/jdsoc2md/lib' },
  order: 1 }
CUSTOM MODULE LIST

MODULE: something
SIG-LINK:
[something](#module_something)

MODULE: anotherthing
SIG-LINK:
[anotherthing](#module_anotherthing)

CUSTOM MODULE LIST END
<a name="module_something"></a>

## something
<a name="module_anotherthing"></a>

## anotherthing

If you have any questions, you can message me using the Gitter room linked on the jsdoc2md README.

75lb commented 5 years ago

dmd-bitbucket is an example of a dmd plugin enabling support for a different markdown renderer (which i think is what you require).

75lb commented 5 years ago

closing, let me know if you have any more questions.