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

Option for the doc command to generate JSON. #2772

Closed
keplersj opened this issue Jun 7, 2016 · 13 comments
Closed

Option for the doc command to generate JSON. #2772

keplersj opened this issue Jun 7, 2016 · 13 comments
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:docs kind:feature status:accepted topic:compiler

Comments

@keplersj
Copy link
Contributor

keplersj commented Jun 7, 2016

Refs rrrene/inch#38.
/cc @rrrene

@rrrene
Copy link

rrrene commented Jun 7, 2016

Hi there,

so the idea is to generate JSON as an option so tools can consume it.

What I would love to see is a JSON dump of every code object (class, module, method, constant, etc.) that was identified. For each of these code objects it would be great to see things like name, type, comment, possibly parameters etc.

If there is anything else I could do to help, just let me know! 👍

@asterite
Copy link
Member

asterite commented Jun 7, 2016

That's exactly the idea :-)

We should define the output format. Ideally it should provide all the information that the current crystal docs show, only in JSON format. This could also be used to generate ctags and other things... and probably to do a docs viewer entirely made by using this JSON output (much lightweight, and probably faster, than the current way of generating static content).

If anyone wants to do this, let me know. The code for crystal doc is more or less easy/clear (I think), you can start from here: https://github.com/crystal-lang/crystal/blob/efd1598bb0965d12a5d113442d297762b0e534ca/src/compiler/crystal/tools/doc.cr

@fernandes Maybe you are interested in doing this? :-)

@asterite asterite added the good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. label Jun 7, 2016
@keplersj
Copy link
Contributor Author

keplersj commented Jun 8, 2016

Should the JSON be printed to STDOUT when using -f json?

@rrrene
Copy link

rrrene commented Jun 8, 2016

Most tools I have encountered handled it this way. I think, unless there are arguments against it, it offers great flexibility as you can pipe that output whereever you want.

But I have to admit I don't know if there are downsides to this on e.g. Windows?

edit: english is hard.

@keplersj
Copy link
Contributor Author

keplersj commented Jun 8, 2016

I wouldn't worry about Windows right now, I think Crystal is still aways away before it'll run on Windows.

@fernandes
Copy link
Contributor

@asterite I'm in! 😎👍

@jhass
Copy link
Member

jhass commented Jun 8, 2016

@fernandes please read issue history carefully, see #2777

@fernandes
Copy link
Contributor

@jhass 👍

@asterite
Copy link
Member

asterite commented Jun 8, 2016

@fernandes Sorry, I didn't think a PR was going to be made after just a few hours of opening this issue. @keplersj Awesome work!

@straight-shoota
Copy link
Member

straight-shoota commented Jul 11, 2017

So there are two outdated PR's in this context: #2777 which adds an additional output type json besides html and #3762 which enhances html output with index files of types and methods in JSON for browser-based search (see #1792)
They both implement JSON serialization though in a different way (#2777 is very basic and uses outdated to_json(io). I think it would make sense to combine these approaches. Basically there are three basic features in this context:

  • JSON serialization for documentable AST nodes
  • alternative output type json for crystal docs
  • enhanced output type html with a json-based index

I am not sure if these should better be addressed in three focused PR's where the first one is obviously a pre-condition for the other two (who are independent of each other).

It is however debatable if the JSON serialization for both use-cases should actually be the same or needs an entirely different implementation. If the index file should only provide search for identifiers (types, constants, method signatures) it only requires a small subset of all available documentation data and would be relatively small in size. If it should also provide full text search, the actual documentation texts need to be present as well, but it is still focused on searchability and needs not be as detailed as for the json output type.

/cc @rosylilly @keplersj

@straight-shoota
Copy link
Member

#4746 has been merged with JSON output. It puts the JSON output alongside the HTML.
Based on that we could also add a --format json option to the docs generator to generate only JSON data and print it to STDOUT.

@RX14 RX14 closed this as completed Nov 3, 2017
@RX14 RX14 reopened this Nov 3, 2017
@RX14
Copy link
Contributor

RX14 commented Nov 3, 2017

A bit hasty on the close button there...

@mniak
Copy link
Contributor

mniak commented Oct 23, 2018

@straight-shoota implemented on PR #6982

@RX14 RX14 closed this as completed in #6982 Dec 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue This is an issue suited for newcomers to become aquianted with working on the codebase. kind:docs kind:feature status:accepted topic:compiler
Projects
None yet
Development

No branches or pull requests

8 participants