Skip to content

Commit

Permalink
docs(completion): skip generated reference policies for completion (#852
Browse files Browse the repository at this point in the history
)

This documentation will just pollute the completion with many items and
is less worthwhile on the command line.

-----

UDENG-1039
  • Loading branch information
didrocks authored Nov 16, 2023
2 parents 26199a4 + ebde18d commit 25acc4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 5 additions & 2 deletions cmd/adsysd/integration_tests/adsysctl_doc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,11 @@ func TestDocCompletion(t *testing.T) {
var wantNumDocs int
docsDir := filepath.Join(rootProjectDir, "docs")
err = filepath.WalkDir(docsDir, func(path string, d fs.DirEntry, err error) error {
// Ignore directories, every reference doc under reuse and compiled content.
if d.IsDir() || strings.HasPrefix(path, filepath.Join(docsDir, "reuse")) || strings.HasPrefix(path, docsDir+"/.") {
// Ignore directories, every reference doc under reuse, compiled content and any autogenerated policy documentation.
if d.IsDir() ||
strings.HasPrefix(path, filepath.Join(docsDir, "reuse")) ||
strings.HasPrefix(path, docsDir+"/.") ||
strings.HasPrefix(path, filepath.Join(docsDir, "reference", "policies")) {
return nil
}
if !strings.HasSuffix(d.Name(), ".md") {
Expand Down
5 changes: 5 additions & 0 deletions internal/adsysservice/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ func docStructure(dir embed.FS, indexFilePath, parentChapterName string) (ordere
}
p = filepath.Join(root, p) + ".md"

// Automated generated policies, ignore them.
if p == "reference/policies/index.md" {
continue
}

title, err := titleFromPage(dir, p)
if err != nil {
return nil, nil, nil, err
Expand Down

0 comments on commit 25acc4c

Please sign in to comment.