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

Renderer for Natural Docs #191

Open
eminakgun opened this issue Jun 28, 2023 · 6 comments
Open

Renderer for Natural Docs #191

eminakgun opened this issue Jun 28, 2023 · 6 comments
Labels

Comments

@eminakgun
Copy link

I need a renderer for natural docs and planning to implement one. ND is primarily targeted for source code documentation but you can include any text in any file extension supporting its parser.
Any suggestions? I am planning to derive from BaseRenderer

@pbodnar
Copy link
Collaborator

pbodnar commented Jun 28, 2023

@eminakgun, I checked https://en.wikipedia.org/wiki/Natural_Docs and I'm not quite sure how mistletoe can help here.

If I get it right, ND parses source codes in a selected programming language and generates an HTML documentation from it. I.e. something similar to Java's javadoc tool. So is your idea to firstly generate markdown from ND and then use mistletoe to convert it to the final HTML form? If so, wouldn't be mistletoe's HTLMRenderer be enough? Or maybe your idea is about something quite different?

@eminakgun
Copy link
Author

eminakgun commented Jun 28, 2023

Not exactly, planning to have the documentation in markdown except code(since ND already does the job for code).
And because HTML output of ND is required, wanna produce ND format from markdown using mistletoe. ND does not only parses the source code, it can scan any file using that uses its syntax. Syntax includes code snippets, titles, lists, images etc. just like markdown does.

I will include an example to be more clear.

@pbodnar
Copy link
Collaborator

pbodnar commented Jun 29, 2023

Thanks for the explanation. 👍 I think the functionality of ND you mention is described within "Text Files" on https://www.naturaldocs.org/getting_started/documenting_your_code/#extra_documentation, right?

So is the motivation for this "Markdown to ND renderer" driven by the fact that the ones who will write these extra documentation files don't even need to know the ND syntax?

Anyway, it looks like you can start by creating a new class called NaturalDocsRenderer, derived from BaseRenderer, with render methods implemented in a way that they return strings / lines in the ND syntax for every given token type. If needed, you can also introduce custom tokens. There is a small piece of documentation for this: https://github.com/miyuchina/mistletoe/blob/master/dev-guide.md#creating-a-custom-renderer. I guess one of the challenges might be handling the indention (at the root level, at minimum) as required by the ND syntax. I've seen it for just a minute by now, so apparently, I cannot give much advice here... ;)

@pbodnar pbodnar added feature and removed question labels Jun 29, 2023
@pbodnar pbodnar changed the title New Renderer Request Renderer for Natural Docs Jun 29, 2023
@eminakgun
Copy link
Author

Thanks for the explanation. 👍 I think the functionality of ND you mention is described within "Text Files" on https://www.naturaldocs.org/getting_started/documenting_your_code/#extra_documentation, right?

Yes.

So is the motivation for this "Markdown to ND renderer" driven by the fact that the ones who will write these extra documentation files don't even need to know the ND syntax?

Exactly.

Anyway, it looks like you can start by creating a new class called NaturalDocsRenderer, derived from BaseRenderer, with render methods implemented in a way that they return strings / lines in the ND syntax for every given token type. If needed, you can also introduce custom tokens. There is a small piece of documentation for this: https://github.com/miyuchina/mistletoe/blob/master/dev-guide.md#creating-a-custom-renderer. I guess one of the challenges might be handling the indention (at the root level, at minimum) as required by the ND syntax. I've seen it for just a minute by now, so apparently, I cannot give much advice here... ;)

Thanks,
I will start digging. Do you suggest to open a draft PR once I got some of the implementation? Then we can figure out if it's right way or not since I'm foreign to the repo.

@pbodnar
Copy link
Collaborator

pbodnar commented Jun 29, 2023

Do you suggest to open a draft PR once I got some of the implementation? Then we can figure out if it's right way or not since I'm foreign to the repo.

Sure, you can open a PR or even draft PR if you need some feedback sooner. :) Just be sure to follow the guidelines and give a unique name to your branch - e.g. feat-191-nd-renderer in this case.

Also I can't promise someone will give you feedback quickly - I'm maintaining mistletoe in my free time and there are already some prioritized issues on the way (some are not even described here yet)...

@eminakgun
Copy link
Author

Alright, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants