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

Add support for JS global objects documentation linking #54

Open
ixti opened this issue Jun 28, 2012 · 10 comments
Open

Add support for JS global objects documentation linking #54

ixti opened this issue Jun 28, 2012 · 10 comments

Comments

@ixti
Copy link
Contributor

ixti commented Jun 28, 2012

It should recognize global objects in the returned values
/**
 *  Foo.bar(a) -> Array
 **/

The above, should replace Array with link to Array documentation.

It should recognize global objects in the arguments definition
/**
 *  Foo.bar(a) -> Array
 *  - a (RegExp): Some description
 **/

The above should replace RegExp with link to RegExp documentation

It should recognize global objects in links
/**
 *  Foo.baz -> String
 *
 *  Serialized representation of self as [[Object]].
 **/

The above should replace [[Object]] with link to Object documentation

By default links to global objects should point MDN. But there should be an option to provide custom URL for global objects documentation (e.g. node.js documentation page).

@Sannis
Copy link
Contributor

Sannis commented Jul 9, 2012

What do you think about references to Node.js classes?

@ixti
Copy link
Contributor Author

ixti commented Jul 9, 2012

I think it should be MDN by default. Here's some extra points that should be considered:

  • allow provide "custom" link format, e.g. http://mydocs.com/js/{name}.html
  • allow provide a way to link format for own "well-known" object, e.g. I want [[Mincer]] to point mincer's documentation.
  • have built-in presets of well known names

I propose to have argument named well-known with ability to specify it multiple time. Format of value should be: <alias>|<names>=<link_fmt>.

  • <alias>: A simple identifier of built-in presets, e.g. @mdn, @node.
  • names: Comma separated list of names, e.g. Object,Array,...
  • link_fmt: Link format for given list of names, e.g. https://mydocs.net/js/{name}.html

According to above:

  • --well-known @mdn equals --well-known Object,Array,...=https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/{name}
  • --well-known @node equals --well-known Buffer,path,...=http://nodejs.org/api/{name:downcase}.html

So it should allow us specify multiple well-known names: --well-known @mdn --well-known @node. Notice that we need to implement filters for variables interpolations (at least downcase and capitalize).

@Sannis
Copy link
Contributor

Sannis commented Jul 9, 2012

Format of value should be: [[<names>=]<link_fmt>].

'=' is bad IMO: --well-known=Object,Array=http://whetever.com/jsdocs/{name}.html breaks my brain.

@ixti
Copy link
Contributor Author

ixti commented Jul 9, 2012

Sorry - I have updated my proposal. I might agree about =. Probably we can use @ symbol:

--well-known @mdn
--well-known Buffer,path@http://nodejs.org/api/{name:downcase}.html

@Sannis
Copy link
Contributor

Sannis commented Jul 9, 2012

I have idea about some usage of : or ;, but you have a better catch.

@ixti
Copy link
Contributor Author

ixti commented Jul 9, 2012

I thought about :, but it's quiet ugly Buffer,path:http://.... And ; will force to either escape it or take argument into quotes.

@puzrin
Copy link
Member

puzrin commented Jul 20, 2012

Why not just use file with simple words mapping?

--references mapping.txt

File content:

Array http://...
Object http://...
Buffer http://

We can attach some default files, or user can use custom one.

Also, that can be added in .ndocrc (1 line per link), since argparse supports appendeable params.

@ixti
Copy link
Contributor Author

ixti commented Jul 20, 2012

I like the idea of reference maps.

@Sannis
Copy link
Contributor

Sannis commented Jul 20, 2012

+1 from me too.

@gjtorikian
Copy link

I have done this in my fork already: https://github.com/gjtorikian/panino-docs/blob/master/additionalObjs.json

I am in the process of updating Panino to the ndoc 2.0 rewrite. I can come back here and paste the relevant code changes if interested. It's just a few updates to the link() function.

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

4 participants