-
Notifications
You must be signed in to change notification settings - Fork 263
Add doc fetch command (download docs from shopify.dev)
#7766
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nelsonwittwer
wants to merge
8
commits into
telemetry-app-context-everywhere
Choose a base branch
from
add-fetch-doc-command
base: telemetry-app-context-everywhere
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
153f7c0
Add `shopify fetch` command to download docs from shopify.dev
nelsonwittwer 7f90212
Address review: rename command to fetch-doc, use allowed-hosts list
nelsonwittwer 173917d
Update e2e command-tree snapshot for fetch-doc
nelsonwittwer 587ae57
Clarify search and fetch-doc command descriptions
nelsonwittwer 8c58c0c
Note in fetch-doc description that shopify.dev serves Markdown for ev…
nelsonwittwer 9b7e62b
Add global flags (--verbose, --no-color) to fetch-doc and search
nelsonwittwer 32e22ff
Add --output flag and drop --content-type from fetch-doc
nelsonwittwer 85aa853
Move `fetch-doc` into the `doc` namespace as `doc fetch`
nelsonwittwer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/cli': minor | ||
| --- | ||
|
|
||
| Add a `shopify doc fetch` command that downloads a document from shopify.dev and prints it to stdout, or writes it to a file with `--output`. It requests the Markdown representation that every shopify.dev page has, giving agents an easy way to pull instructional content from the centralized docs verbatim. |
24 changes: 24 additions & 0 deletions
24
docs-shopify.dev/commands/interfaces/doc-fetch.interface.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| // This is an autogenerated file. Don't edit this file manually. | ||
| /** | ||
| * The following flags are available for the `doc fetch` command: | ||
| * @publicDocs | ||
| */ | ||
| export interface docfetch { | ||
| /** | ||
| * Disable color output. | ||
| * @environment SHOPIFY_FLAG_NO_COLOR | ||
| */ | ||
| '--no-color'?: '' | ||
|
|
||
| /** | ||
| * Write the document to this file path instead of printing it to stdout. | ||
| * @environment SHOPIFY_FLAG_OUTPUT | ||
| */ | ||
| '-o, --output <value>'?: string | ||
|
|
||
| /** | ||
| * Increase the verbosity of the output. | ||
| * @environment SHOPIFY_FLAG_VERBOSE | ||
| */ | ||
| '--verbose'?: '' | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| import {docFetchService} from '../../services/commands/doc/fetch.js' | ||
| import Command from '@shopify/cli-kit/node/base-command' | ||
| import {globalFlags} from '@shopify/cli-kit/node/cli' | ||
| import {Args, Flags} from '@oclif/core' | ||
|
|
||
| export default class DocFetch extends Command { | ||
| static description = | ||
| 'Download a complete document from shopify.dev. Every page on shopify.dev has a Markdown version, and that is what this tool returns. Use this to pull an entire document verbatim — for example, a set of instructions an agent follows like a centrally-served skill. For finding the relevant pieces of content across shopify.dev instead, use `doc search`.' | ||
|
|
||
| static usage = `doc fetch [URL]` | ||
|
|
||
| static examples = [ | ||
| `# fetch the Markdown version of a Shopify.dev page | ||
| shopify doc fetch https://shopify.dev/docs/api/shopify-cli`, | ||
| `# save the document to a file instead of printing it | ||
| shopify doc fetch https://shopify.dev/docs/api/shopify-cli --output docs/shopify-cli.md`, | ||
| ] | ||
|
|
||
| static args = { | ||
| url: Args.string({ | ||
| name: 'url', | ||
| required: true, | ||
| description: 'The shopify.dev URL to fetch.', | ||
| }), | ||
| } | ||
|
|
||
| static flags = { | ||
| ...globalFlags, | ||
| output: Flags.string({ | ||
| char: 'o', | ||
| description: 'Write the document to this file path instead of printing it to stdout.', | ||
| env: 'SHOPIFY_FLAG_OUTPUT', | ||
| }), | ||
| } | ||
|
|
||
| async run(): Promise<void> { | ||
| const {args, flags} = await this.parse(DocFetch) | ||
| await docFetchService(args.url, flags.output) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.