feat(internal/godocfx): add support for other modules#4290
feat(internal/godocfx): add support for other modules#4290gcf-merge-on-green[bot] merged 6 commits intomasterfrom
Conversation
I chose to process all modules at the same time, rather than in separate invocations of godocfx, so we wouldn't have to make duplicate requests to the module index. The docs.metadata generation will probably need to be updated in a future PR to support different final URL destinations.
shollyman
left a comment
There was a problem hiding this comment.
My comments are largely borne of lack of familiarity with the project, feel free to ignore if they're irrelevant.
| modPath = strings.TrimSuffix(modPath, "/...") // No /... needed. | ||
| mods = []indexEntry{ | ||
| { | ||
| modPath = strings.TrimSuffix(modPath, "/...") // No /... needed. |
There was a problem hiding this comment.
Unclear to me end to end how module strings are moving through the system, do you ever need to sanitize trailing comments?
There was a problem hiding this comment.
I'm not sure what you mean by trailing comments. This comes from a command line argument. This makes sure that if the user did include the /... at the end, we handle it transparently. A previous version of this command passed the argument through directly, and I made use of /..., so I didn't want to break that.
| ic := fakeIC{} | ||
| ts := &fakeTS{} | ||
| entries, err := newModules(context.Background(), ic, ts, "cloud.google.com") | ||
| entries, err := newModules(context.Background(), ic, ts, []string{"cloud.google.com"}) |
There was a problem hiding this comment.
Maybe include an entry with explicit versioning and maybe something that exercises the filter paths?
There was a problem hiding this comment.
This test really just makes sure the paging logic works for the index. It doesn't exercise the prefix logic, which is a gap in coverage. Can try to figure out how to add a test for it (need to refactor the HTTP calls) if you feel strongly.
| // indexer gets a limited list of entries from index.golang.org. | ||
| type indexer interface { | ||
| get(prefix string, since time.Time) (entries []indexEntry, last time.Time, err error) | ||
| get(prefixes []string, since time.Time) (entries []indexEntry, last time.Time, err error) |
There was a problem hiding this comment.
Are overlapping prefixes an issue that may need consideration?
There was a problem hiding this comment.
No, I don't think so. We won't process duplicate modules because we don't process each prefix independently -- if a module matches any prefix, it's included.
| // indexer gets a limited list of entries from index.golang.org. | ||
| type indexer interface { | ||
| get(prefix string, since time.Time) (entries []indexEntry, last time.Time, err error) | ||
| get(prefixes []string, since time.Time) (entries []indexEntry, last time.Time, err error) |
There was a problem hiding this comment.
No, I don't think so. We won't process duplicate modules because we don't process each prefix independently -- if a module matches any prefix, it's included.
| ic := fakeIC{} | ||
| ts := &fakeTS{} | ||
| entries, err := newModules(context.Background(), ic, ts, "cloud.google.com") | ||
| entries, err := newModules(context.Background(), ic, ts, []string{"cloud.google.com"}) |
There was a problem hiding this comment.
This test really just makes sure the paging logic works for the index. It doesn't exercise the prefix logic, which is a gap in coverage. Can try to figure out how to add a test for it (need to refactor the HTTP calls) if you feel strongly.
| modPath = strings.TrimSuffix(modPath, "/...") // No /... needed. | ||
| mods = []indexEntry{ | ||
| { | ||
| modPath = strings.TrimSuffix(modPath, "/...") // No /... needed. |
There was a problem hiding this comment.
I'm not sure what you mean by trailing comments. This comes from a command line argument. This makes sure that if the user did include the /... at the end, we handle it transparently. A previous version of this command passed the argument through directly, and I made use of /..., so I didn't want to break that.
I chose to process all modules at the same time, rather than in separate
invocations of godocfx, so we wouldn't have to make duplicate requests
to the module index.
The docs.metadata generation will probably need to be updated in a
future PR to support different final URL destinations.