Update testable-code report to scan docs monorepo content directories#6
Update testable-code report to scan docs monorepo content directories#6krollins-mdb merged 5 commits intomainfrom
testable-code report to scan docs monorepo content directories#6Conversation
- Introduced a new `resolve` command with a subcommand `url` to resolve source .txt files to their production URLs. - Implemented URL resolution logic in `commands/resolve/url/resolver.go`. - Added tests for URL construction and resolution functionality. - Updated main command to include the new resolve command.
- Add `--for-docs-set` flag to scan all pages in specified content directories instead of requiring a CSV file - Add `--current-only` flag to filter to current version pages when scanning docs sets (default: true) - Add `--base-url` flag for resolving page URLs (default: https://www.mongodb.com/docs) - Add `DocsSet` field to PageEntry and PageReport to track content directory name - Add computed fields to PageReport: `TotalUntested` (TotalExamples - TotalTested) and `NeedsToBeTested` (true if TotalTestable > TotalTested) - Make source paths relative to content directory in CSV output for better readability - Update command usage to support both CSV mode and docs set scanning mode - Make CSV file argument optional when using docs set mode
|
|
||
| ### Resolve Commands | ||
|
|
||
| #### `resolve url` |
There was a problem hiding this comment.
[nit] why not use hyphen? or are we expecting additional resolve subcommands
There was a problem hiding this comment.
Possibly! I wanted to leave the possibility open. For example, we could have a resolve command for getting the content location of one or more tested code examples.
| ./audit-cli resolve url content/compass/source/index.txt | ||
| # Output: https://www.mongodb.com/docs/compass/ | ||
|
|
||
| # Use a different base URL (e.g., for staging) |
| // The URL slug is the path component after /docs/ in the production URL. | ||
| // For example, "golang" maps to "drivers/go", so the URL would be: | ||
| // https://www.mongodb.com/docs/drivers/go/current/ | ||
| var projectToURLSlug = map[string]string{ |
There was a problem hiding this comment.
is this something that could be extracted for common use?
There was a problem hiding this comment.
Certainly! I'm not sure where else it would be useful. Happy to extract it as its own command if it makes sense to do so.
| for _, docsSet := range docsSets { | ||
| docsSetPath := filepath.Join(contentDir, docsSet) | ||
| if _, err := os.Stat(docsSetPath); os.IsNotExist(err) { | ||
| return nil, fmt.Errorf("docs set not found: %s", docsSet) |
There was a problem hiding this comment.
do we want to include the docsSetPath in the error message?
There was a problem hiding this comment.
do we want to accumulate errors and continue if docs sets aren't found/are bad, rather than kill the whole run? maybe give an error report
There was a problem hiding this comment.
I like both of those ideas. Made a change to how the errors are handled. They'll be printed at the end of a run as a separate report.
|
|
||
| **Flags:** | ||
|
|
||
| - `--base-url <url>` - Base URL for production documentation (default: `https://www.mongodb.com/docs`) |
There was a problem hiding this comment.
what about version as a flag?
There was a problem hiding this comment.
I've added one and updated the docs for the report testable-code command. Good idea!
…de and version filtering
…po path configuration
Updates the
testable-codereport command to take arbitrary docs set directories in the monorepo as input using--for-docs-set. For example,--for-docs-set cloud-docs,golang,node. Also added aURLcolumn to the report that includes the page's production URL for reference and changed the source file path to be relative to thecontentdirectory in the monrepo, rather than an absolute path for the machine the command is run on.Also added a new
resolve urlcommand, which maps documentation source files to their production URLs. This logic uses the docs TOC as its source of truth instead of the Snooty Data API.Image of a cute animal