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

nested ouput #129

Closed
ouhouhsami opened this issue Sep 4, 2014 · 1 comment
Closed

nested ouput #129

ouhouhsami opened this issue Sep 4, 2014 · 1 comment

Comments

@ouhouhsami
Copy link

Hi,

First, thanks for this library.

I was wondering about the possibility to output a nested json of the javascript code documentation.
For the moment, the output is flat, and it could be relevant to have a nested output based on, may be the the curly braces indentation.

For my use case, I have es6 class, like this

/*
* @class A
*/
class A {
/*
* foo
*/
 foo(){
 }
} 

And it would be great to have json like this:

  {
    "tags": [
      {
        "type": "class",
        "string": "A"
      }
    ],
    "isPrivate": false,
    "ignore": false,
    "code": "....",
    "children" : [
        {
        "tags": [{"type": "function", "string": "foo"} ]
        }
    ]
  }

This issue seems to be more or less like this PR : #73 but with and easier use of the output.

What do you think about it ?

@Twipped
Copy link
Collaborator

Twipped commented Sep 4, 2014

Currently dox doesn't know anything about the class syntax, so that would have to be fixed first, but there's another issue in the way. Dox doesn't parse code blocks, at least no more than what it needs to determine the context of the declaration the comment is for. It has no concept of brackets and object definitions, it just processes comment blocks one at a time and assumes anything between comments belongs to the previous comment.

PR #107 (and by extension, #128) adds a bit of code for detecting some parent names on specific use cases, and #85 adds some nesting support for @lends tags, but it's all kind of hacky and only works for specific implementations.

Properly detecting nesting such as what you're looking for would require a different implementation, something more akin to esprima (which people keep saying needs to be rewritten).

That said, you could accomplish 90% of this today through the use of @memberOf tags and post-processing of the dox output to map parent->child relationships.

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

2 participants