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

Calculate Documentation Percentage #64

Open
leogdion opened this issue Dec 9, 2020 · 7 comments
Open

Calculate Documentation Percentage #64

leogdion opened this issue Dec 9, 2020 · 7 comments

Comments

@leogdion
Copy link
Contributor

leogdion commented Dec 9, 2020

I know some documentation tools have the ability to return the percentage documented. I'd love something like this to include in my CI along with SourceDocs. I am more than willing to help as well and add this feature. Where would something like this be calculated and added?

@eneko
Copy link
Collaborator

eneko commented Dec 11, 2020

Hi @leogdion, thank you for the suggestion. This is an interesting topic, and feature.

Where to calculate the percentage will depend on your definition:

  • Should the total percentage be in the README file?
  • Should it be on each document file?
  • Maybe we would want a sourcedocs percentage command that prints the total percentage without generating any other output?

In terms of calculation, SourceDocs loads all entities (classes, methods, etc) from code, whether they are documented or not. We could count the number of entities that have documentation and calculate the percentage. The best place to do that would probably be in MarkdownIndex.swift.

@leogdion
Copy link
Contributor Author

leogdion commented Dec 11, 2020

I was thinking something fairly simple:

  • Maybe we would want a sourcedocs percentage command that prints the total percentage without generating any other output?

In other words just output the value with the command output (not included in any markdown files). My intention is to include it as part of my pre-commit hook or CI to ensure my documentation is up to certain threshold similar to how I can use swift-test-codecov in my pre-commit hook to ensure my test code coverage is fulfilled.

Feel free to look at how I do this with MistKit and code coverage. I'm going to look at MarkdownIndex.swift and see what I can do there.

Thanks for the pointers!

@eneko
Copy link
Collaborator

eneko commented Dec 11, 2020

Nice. That would be a great tool, for sure. It might require some good amount of refactoring, to separate the documentation extraction logic from the markdown generation (right now it's all tangled together 🙈).

If you want to look into it, I would recommend starting by adding a new command, then running the SourceKitten calls to parse the source files and load documentation. Feel free to duplicate any code, if you want to go this route, we can tidy it up later.

@leogdion
Copy link
Contributor Author

I posted #65
Let me know if it needs any further fixes.

@eneko
Copy link
Collaborator

eneko commented Dec 14, 2020

Will take a look, thanks

@leogdion
Copy link
Contributor Author

Cool! Let me know if you have any questions.

@eneko
Copy link
Collaborator

eneko commented Dec 28, 2020

Hi @leogdion, just left you a comment on the PR. please try pulling the latest changes from the main branch (master branch is no longer used).

If you don't mind, and have the time, it would be nice to clean up the command, specially all the parameters (arguments) not being used or needed for this command. Instead, you can pass default values to the documentation generator.

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