Skip to content

Commit

Permalink
0.34.x gen doc links (#573)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheidkamp authored Nov 18, 2024
1 parent 9495e89 commit c961dd6
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
6 changes: 6 additions & 0 deletions changelog/v0.34.4/no-external-links.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
changelog:
- type: FIX
issueLink: https://github.com/solo-io/solo-projects/issues/6768
resolvesIssue: false
description: >-
Update protobuf processing to no longer render links to locally hosted external API docs, as they are being removed.
9 changes: 8 additions & 1 deletion pkg/code-generator/docgen/funcs/template_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,15 @@ func linkForField(project *model.Project, docsOptions *options.DocsOptions) func
linkedFile = filepath.Base(file.GetName())
//return "", errors.Errorf("failed to get generated file path for proto %v in list %v", file.GetName(), project.Request.FileToGenerate)
}
linkedFile = relativeFilename(forFile.GetName(), linkedFile)

// Skip links for packages that are configured to be skipped
for _, pkg := range docsOptions.RenderOptions.GetSkipLinksForPathPrefixes() {
if strings.HasPrefix(linkedFile, pkg) {
return typeName, nil
}
}

linkedFile = relativeFilename(forFile.GetName(), linkedFile)
if docsOptions.Output == options.Restructured {
linkText = ":ref:`message." + strings.TrimPrefix(field.GetTypeName(), ".") + "`"
} else {
Expand Down
19 changes: 17 additions & 2 deletions pkg/code-generator/docgen/options/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,23 @@ type HugoOptions struct {
}

type DocsOptions struct {
Output DocsOutput
HugoOptions *HugoOptions
Output DocsOutput
HugoOptions *HugoOptions
RenderOptions *RenderOptions
}

// RenderOptions provides options for rendering documentation
type RenderOptions struct {
// SkipLinksForPathPrefixes is a list of file path prefixes of APIs to which we should not be attempting to link
// For example: "github.com/solo-io/gloo/projects/gloo/api/external"
SkipLinksForPathPrefixes []string
}

func (o *RenderOptions) GetSkipLinksForPathPrefixes() []string {
if o == nil {
return nil
}
return o.SkipLinksForPathPrefixes
}

const (
Expand Down

0 comments on commit c961dd6

Please sign in to comment.