Skip to content

Commit

Permalink
make link changes configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
sheidkamp committed Nov 14, 2024
1 parent 5e2965c commit 415c33b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
8 changes: 5 additions & 3 deletions pkg/code-generator/docgen/funcs/template_funcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,9 +319,11 @@ func linkForField(project *model.Project, docsOptions *options.DocsOptions) func
//return "", errors.Errorf("failed to get generated file path for proto %v in list %v", file.GetName(), project.Request.FileToGenerate)
}

// Don't link to external apis docs, as they will be deleted
if strings.HasPrefix(linkedFile, "github.com/solo-io/gloo/projects/gloo/api/external") {
return typeName, nil
// Skip links for packages that are configured to be skipped
for _, pkg := range docsOptions.RenderOptions.GetSkipLinksForPackages() {
if strings.HasPrefix(linkedFile, pkg) {
return typeName, nil
}
}

linkedFile = relativeFilename(forFile.GetName(), linkedFile)
Expand Down
17 changes: 15 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,21 @@ 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 {
SkipLinksForPackages []string // when rendering markdown, do not attempt to link to these packages or their subpackages
}

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

const (
Expand Down

0 comments on commit 415c33b

Please sign in to comment.