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

JSON output now parses description and moduleDescription as JSON #14871

Closed
wants to merge 3 commits into from

Conversation

PMunch
Copy link
Contributor

@PMunch PMunch commented Jul 1, 2020

This means that the JSON output format can be used to output other document formats like Markdown.

Documentation created with `jsondoc` will now have the actual
description and module description as a parsed tree of JSON nodes that
can more easily be turned into different formats or entered into a
database.
@Araq
Copy link
Member

Araq commented Jul 2, 2020

I like it but since it adds yet more code to the Nim compiler, please make nimdoc a tool of its own. nim doc can call nimdoc for backwards compat.

@PMunch
Copy link
Contributor Author

PMunch commented Jul 2, 2020

That would require the separate tool to understand the Nim command line syntax as well though, meaning that e.g. switches would need to be reflected in both places. Is this really the best way? I guess the compiler could only spit out the machine-readable JSON doc format, and then the external tool could translate it to HTML/Latex/whatever. That way the compiler will stay small, the docgen and rstgen parts would be greatly simplified, and the JSON format would be guaranteed to be up-to-date with the latest documentation generation (so we avoid the jsondoc1 -> 2 cleanup I did).

@Araq
Copy link
Member

Araq commented Jul 2, 2020

Is this really the best way?

It's what nimsuggest does too.

@timotheecour
Copy link
Member

I guess the compiler could only spit out the machine-readable JSON doc format, and then the external tool could translate it to HTML/Latex/whatever.

this is the best way forward and also what I recommended here #14439 (comment) (ignore the 2nd paragraph macros should be powerful enough to enable full reflection and 100% replace docgen, which is a separate topic that I don't want to bring up here)

there are multiple ways to do that, here's one:

  • nim jsondoc -o:foo.json [options] main produces foo.json
  • nimdoc --mode:html|pdf|latex|tex --outdir:dir foo.json produces actual docs; and running runnableExamples depending on options passed in
  • nim doc [options] main calls nim jsondoc and then nimdoc with appropriate options by shelling out, to reproduce pre-existing behavior

=> no code breaks, it'd be a transparent change for users
=> compiler logic is cleansed from RST parsing etc
=> no code duplication either

@PMunch
Copy link
Contributor Author

PMunch commented Jul 3, 2020

Hmm, I think nim jsondoc should run the tests, that way nimdoc doesn't really need to know anything about Nim or how to compile Nim code. It would just be a pure JSON -> output format converter. But otherwise that's exactly what I had in mind.

@timotheecour
Copy link
Member

Hmm, I think nim jsondoc should run the tests

fine with that

@narimiran
Copy link
Member

This is rebased on the latest devel, with resolved merge conflicts, in PR #15999.

I guess we can continue the discussion there.

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

Successfully merging this pull request may close these issues.

4 participants