Skip to content

feat: Generate source plugin docs#47

Merged
hermanschaaf merged 10 commits intomainfrom
generate-docs
Sep 6, 2022
Merged

feat: Generate source plugin docs#47
hermanschaaf merged 10 commits intomainfrom
generate-docs

Conversation

@hermanschaaf
Copy link
Copy Markdown
Contributor

Adds the ability to generate markdown docs for source plugins. Mostly migrated from cq-provider-sdk with minor tweaks and new tests.

Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. few minor comments.

docs/source.go Outdated

// GenerateSourcePluginDocs creates table documentation for the source plugin based on its list of tables
func GenerateSourcePluginDocs(p *plugins.SourcePlugin, outputPath string, deleteOld bool) error {
if deleteOld {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should never delete files and it should be part of someone script if he wants to delete everything and regenerated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yevgenypats I agree, but this will lead to a lot of duplication since all the plugins will need this functionality, and we don't want them to share common libraries in the monorepo.

How about we remove the option here, but we add a convenience function for deleting directories to the SDK, maybe in another package?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a helper function in this commit: 3ac2962

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually meant for us to something like rm -rf *.md && go run main.go doc so a helper function wont be needed because it highly depends on what is in the directory and specifaclly in our case what is in our website so it can also be something like rm -rf cloudquery*.md . I think in cobra there is also no logic around deleting - https://github.com/spf13/cobra/blob/main/doc/md_docs.go

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I see! Okay yeah, makes sense. I'll remove the delete functionality from this PR and update the scripts to run something like rm -rf *.md in a follow-up where we migrate to this implementation.

}

outputPath := filepath.Join(dir, fmt.Sprintf("%s.md", table.Name))
f, err := os.Create(outputPath)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be truncated as a default behaviour.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No change needed here I believe, os.Create creates or truncates the named file. If the file already exists, it is truncated.

@hermanschaaf hermanschaaf merged commit e00d970 into main Sep 6, 2022
@hermanschaaf hermanschaaf deleted the generate-docs branch September 6, 2022 12:27
@cq-bot cq-bot mentioned this pull request Sep 6, 2022
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.

2 participants