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 option to append to existing output files if non-API documentation content exists #55

Closed
jdpedrie opened this issue Dec 7, 2021 · 3 comments · Fixed by #59
Closed

Comments

@jdpedrie
Copy link

jdpedrie commented Dec 7, 2021

Hi, first of all I love this project. I'm super excited to find a godoc style generator that works for private projects.

I integrated the generator into my project for work, but found that outputting to README.md would clobber any existing README data, so the initial solution is to send output to a separate file: gomarkdoc --output '{{.Dir}}/DOCUMENTATION.md' ./....

This works fine, but visibility is lower. I'd love for this tool to detect an existing README.md file, and append documentation to the end, rather than overriding the existing content. Ideally it could detect the comment at the start of the generated documentation, split the file contents, and replace the existing documentation on regeneration.

@jdpedrie jdpedrie changed the title Add option to append to existing README.md files Add option to append to existing output files if non-API documentation content exists Dec 7, 2021
@princjef
Copy link
Owner

Thanks for the suggestion @jdpedrie! I think this would be a great addition to the tool. Based on what I've seen in other tools I would think a comment marker like this would be reasonable:

<!-- gomarkdoc:embed -->

Then when the documentation gets inserted, that would get replaced with:

<!-- gomarkdoc:embed:start -->

The generated documentation...

<!-- gomarkdoc:embed:end -->

The tool would be designed to work with either the individual comment or the pair, replacing any text in between the start and end markers in variation 2.

Thoughts?

@jdpedrie
Copy link
Author

Hey @princjef, thanks for the reply!

I think your suggestion makes sense in cases where a file which would be modified already exists. For instance, a package with a README.md file should probably specify the embed location. Perhaps that, combined with creating new files when an existing one does not exist, would be a good solution?

In my project (a fairly large monorepo), for instance, we have a number of packages which do not have READMEs.

@princjef
Copy link
Owner

princjef commented Jan 6, 2022

This has been released in https://github.com/princjef/gomarkdoc/releases/tag/v0.3.1

Take it for a spin and let me know if you run into any issues or have any additional thoughts!

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 a pull request may close this issue.

2 participants