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

Update Godoc for internal structs/funcs to clarify the package they are exposed under #1735

Merged
merged 8 commits into from
Dec 6, 2024

Conversation

yuandrew
Copy link
Contributor

@yuandrew yuandrew commented Dec 2, 2024

What was changed

Added a new tool that identifies public structs/funcs that map to internal fields, and detects if the internal fields have a doc comment referring to where it's publicly exposed as.

Passing by with no flags will only output missing mappings to stdout, but passing in -fix will automatically generate the mapping comments.

Why?

Clarity

Checklist

  1. Closes Update Godoc for internal structs/funcs to clarify the package they are exposed under #1681

  2. How was this tested:

Manually inspected output

@yuandrew yuandrew force-pushed the godoc-internal-clarity branch from 882b677 to e1c3991 Compare December 5, 2024 22:15
@yuandrew yuandrew marked this pull request as ready for review December 5, 2024 22:16
@yuandrew yuandrew requested a review from a team as a code owner December 5, 2024 22:16
@@ -39,11 +39,15 @@ import (

type (
// ActivityType identifies an activity type.
//
// Exposed as: activity:Type
Copy link
Contributor

Choose a reason for hiding this comment

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

hm Can we make these doc links https://tip.golang.org/doc/comment#doclinks?

Copy link
Contributor

Choose a reason for hiding this comment

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

That way they are navigable

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yeah, good idea. Unfortunately it's not as clean because we have to import the entire package name, i.e. go.temporal.io/sdk/temporal.ApplicationError, but clickable is better

will return original type of error represented as string. Workflow code could check this type to determine what kind of error it was
and take actions based on the type. These errors are retryable by default, unless error type is specified in retry policy.
*ApplicationError can be returned in two cases:
- If activity implementation returns *ApplicationError by using NewApplicationError()/NewNonRetryableApplicationError() API.
Copy link
Contributor

Choose a reason for hiding this comment

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

There appears to be some unnecessary whitespace changes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oops, this was because I was stripping whitespace at the beginning and ending of lines, and format.Source([]byte(newFile)) won't automatically add back spacing to comments. Fixed!

return publicToInternal, nil
}

func isPublic(name string) bool {
Copy link
Member

Choose a reason for hiding this comment

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

log.Fatal(err)
}
if missing {
log.Fatal("Missing documentation, see previous stdout for which objects. Re-run command with -fix to auto-generate missing docs.")
Copy link
Member

Choose a reason for hiding this comment

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

This is great that it gives a bad exit code on missing docs. Can you add this step to CI?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

Ah, great, sorry I missed that

@yuandrew yuandrew enabled auto-merge (squash) December 6, 2024 19:12
@yuandrew yuandrew merged commit 7828e06 into temporalio:master Dec 6, 2024
13 checks passed
@yuandrew yuandrew deleted the godoc-internal-clarity branch December 6, 2024 19:32
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.

Update Godoc for internal structs/funcs to clarify the package they are exposed under
3 participants