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

Is there a way to omit certain functions? #109

Open
mikeym88 opened this issue Aug 9, 2023 · 2 comments
Open

Is there a way to omit certain functions? #109

mikeym88 opened this issue Aug 9, 2023 · 2 comments

Comments

@mikeym88
Copy link

mikeym88 commented Aug 9, 2023

I would like to generate documentation for a package in a project, but I only want to output certain functions (based on our internal naming convention). Is there a way to do designate which functions are included in the doc generation? Or must I use a gotxt template for this?

Would it be possible to get examples of how to do this with and without template files, if possible?

@princjef
Copy link
Owner

Hi @mikeym88, there is currently no way to exclude functions or types based on their names when invoking the tool. It should be possible, if a bit clunky, to achieve with gotxt files. You would want to use a template override to replace the func and index templates. You can copy them from the default files and modify them to fit your needs. In the func template, you would need an if/else to exclude all output for the functions in question. and in index you'd want to exclude the funcs from the loop that adds them to the index.

With that said, there are still some edge cases around linking, etc. that would be difficult to resolve with pure gotxt templates. It may be reasonable to add an option to exclude certain symbols. If you can give me example of what types of names you want to exclude that might help me determine the feasibility/desired behavior of such a feature

@mikeym88
Copy link
Author

@princjef Thanks for the reply. I ended up figuring out, and I did create custom template files for it.

I created a small utility written in Go that uses gomarkdoc with custom functions added to the templates, namely Contains, HasSuffix, HasPrefix and TrimSpace from the strings package. I was hoping to be able to pass the functions (or at least their names) from the command-line, but that might not be possible?

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