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

@see <namepath> not supported #98

Open
rhys-vdw opened this issue Jun 2, 2016 · 3 comments
Open

@see <namepath> not supported #98

rhys-vdw opened this issue Jun 2, 2016 · 3 comments
Labels

Comments

@rhys-vdw
Copy link

rhys-vdw commented Jun 2, 2016

/**
 * Both of these will link to the bar function.
 * @see {@link bar}
 * @see bar
 */
function foo() {}

docs

Input:

/** @see Class#method */

Output with jsdoc to markdown:

**See:** Class#method

Should be:

**See:** [Class#method](Class+method)

I've been looking through the ddata source trying to work out how to make this change. Not entirely sure if this is a jsdoc-parse issue or a dmd issue. Either way I'm happy to submit a PR.

@75lb
Copy link
Member

75lb commented Jun 2, 2016 via email

@rhys-vdw
Copy link
Author

rhys-vdw commented Jun 2, 2016

Not sure how formal the spec for @see is, but this is my quick fix in my plugin:

helpers.js

var ddata = require('ddata');

exports.linkifyOrInlineLinks = linkifyOrInlineLinks;

/**
replaces {@link} tags with markdown links in the suppied input text.
if no links are found, then assume this is a valid link target.
*/
function linkifyOrInlineLinks (text, options) {
  if (text) {
    var links = ddata.parseLink(text);
    if (links.length > 0) {
      links.forEach(function (link) {
        var linked = ddata._link(link.url, options)
        if (link.caption === link.url) link.caption = linked.name
        if (linked.url) link.url = linked.url
        text = text.replace(link.original, '[' + link.caption + '](' + link.url + ')')
      })
    } else {
      var linked = ddata._link(text, options)
      text = '[' + linked.name + '](' + linked.url + ')';
    }
  }
  return text
}

see.hbs

{{#if see~}}

{{#if (equal see.length 1)~}}
**See**: {{{linkifyOrInlineLinks see.[0]}}}  
{{else~}}
**See**

{{#each see}}- {{{linkifyOrInlineLinks this}}}
{{/each}}

{{/if~}}
{{/if~}}

@75lb
Copy link
Member

75lb commented Aug 9, 2016

Apologies for the delay! Yes, you're right - @see does not seem to parse namepaths which is a glaring oversight on my behalf.. I'd gratefully accept a PR but the handlebars templates/helpers are a not particularly inviting to work on, which is my main long-term goal to solve..


Try the jsdoc2md v2 pre-release

@75lb 75lb added the bug label Aug 9, 2016
@75lb 75lb transferred this issue from jsdoc2md/jsdoc-to-markdown Sep 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants