Skip to content

Commit e8a48e3

Browse files
authored
chore(docs): Redesign docs CLI tools for creating and editing content, add content/create.md tutorial page for the How to creat… (#6506)
* chore(docs): Add content/create.md tutorial page for the How to create your own documentation tutorial chore(scripts): docs:create and docs:edit scripts for content creation and editing Major improvements to docs:create UX for both Claude Code and external tool integration: **New `docs` CLI command:** - Add scripts/docs-cli.js - main CLI with subcommand routing - Add bin field to package.json for `docs` command - Usage: `docs create` and `docs edit` (cleaner than yarn commands) **Smart piping detection:** - Auto-detect when stdout is piped (\!process.stdout.isTTY) - When piping: automatically output prompt text (no flag needed) - When interactive: output prompt file path - --print-prompt flag now optional (auto-enabled when piping) **Specify products:** - simplify link following behavior - treat relative paths as local files, all HTTP/HTTPS as external - stdin now requires --products flag with product keys - --products now accepts keys from products.yml (influxdb3_core, telegraf, etc.) Examples: --products influxdb3_core --products influxdb3_core,influxdb3_enterprise --products telegraf **Usage examples:** # Inside Claude Code - automatic execution docs create drafts/new-feature.md # Pipe to external AI - prompt auto-detected docs create FILE --products X | claude -p docs create FILE --products X | copilot -p # Pipe from stdin echo 'content' | docs create --products X | claude -p Benefits: - Cleaner syntax (no yarn --silent needed) - No manual --print-prompt flag when piping - Consistent with industry tools (git, npm, etc.) - Backward compatible with yarn commands WIP: docs:create usage examples - Redesign of the docs CLI tools for creating and editing content - Cleaner interface works better for piping output to agents and downstream utilities - Updates README.md and other authoring docs This repository includes a `docs` CLI tool for common documentation workflows: ```sh npx docs create drafts/new-feature.md --products influxdb3_core npx docs edit https://docs.influxdata.com/influxdb3/core/admin/ npx docs placeholders content/influxdb3/core/admin/upgrade.md npx docs --help ``` **Run test cases:** ```sh npx docs test ``` * Update content/create.md * Update content/create.md * Update content/create.md * Update content/create.md * Update scripts/templates/chatgpt-prompt.md * Update DOCS-SHORTCODES.md
1 parent efd288f commit e8a48e3

File tree

14 files changed

+1298
-266
lines changed

14 files changed

+1298
-266
lines changed

DOCS-SHORTCODES.md

Lines changed: 90 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Complete reference for custom Hugo shortcodes used in InfluxData documentation.
1919
- [Content Management](#content-management)
2020
- [Special Purpose](#special-purpose)
2121

22-
---
22+
***
2323

2424
## Notes and Warnings
2525

@@ -146,7 +146,7 @@ Use the `{{< api-endpoint >}}` shortcode to generate a code block that contains
146146
- **method**: HTTP request method (get, post, patch, put, or delete)
147147
- **endpoint**: API endpoint
148148
- **api-ref**: Link the endpoint to a specific place in the API documentation
149-
- **influxdb_host**: Specify which InfluxDB product host to use _if the `endpoint` contains the `influxdb/host` shortcode_. Uses the current InfluxDB product as default. Supports the following product values:
149+
- **influxdb_host**: Specify which InfluxDB product host to use *if the `endpoint` contains the `influxdb/host` shortcode*. Uses the current InfluxDB product as default. Supports the following product values:
150150
- oss
151151
- cloud
152152
- serverless
@@ -268,11 +268,11 @@ To link to tabbed content, click on the tab and use the URL parameter shown. It
268268

269269
Use the `{{< page-nav >}}` shortcode to add page navigation buttons to a page. These are useful for guiding users through a set of docs that should be read in sequential order. The shortcode has the following parameters:
270270

271-
- **prev:** path of the previous document _(optional)_
272-
- **next:** path of the next document _(optional)_
273-
- **prevText:** override the button text linking to the previous document _(optional)_
274-
- **nextText:** override the button text linking to the next document _(optional)_
275-
- **keepTab:** include the currently selected tab in the button link _(optional)_
271+
- **prev:** path of the previous document *(optional)*
272+
- **next:** path of the next document *(optional)*
273+
- **prevText:** override the button text linking to the previous document *(optional)*
274+
- **nextText:** override the button text linking to the next document *(optional)*
275+
- **keepTab:** include the currently selected tab in the button link *(optional)*
276276

277277
The shortcode generates buttons that link to both the previous and next documents. By default, the shortcode uses either the `list_title` or the `title` of the linked document, but you can use `prevText` and `nextText` to override button text.
278278

@@ -308,7 +308,7 @@ The children shortcode can also be used to list only "section" articles (those w
308308
{{< children show="pages" >}}
309309
```
310310

311-
_By default, it displays both sections and pages._
311+
*By default, it displays both sections and pages.*
312312

313313
Use the `type` argument to specify the format of the children list.
314314

@@ -325,15 +325,15 @@ The following list types are available:
325325

326326
#### Include a "Read more" link
327327

328-
To include a "Read more" link with each child summary, set `readmore=true`. _Only the `articles` list type supports "Read more" links._
328+
To include a "Read more" link with each child summary, set `readmore=true`. *Only the `articles` list type supports "Read more" links.*
329329

330330
```md
331331
{{< children readmore=true >}}
332332
```
333333

334334
#### Include a horizontal rule
335335

336-
To include a horizontal rule after each child summary, set `hr=true`. _Only the `articles` list type supports horizontal rules._
336+
To include a horizontal rule after each child summary, set `hr=true`. *Only the `articles` list type supports horizontal rules.*
337337

338338
```md
339339
{{< children hr=true >}}
@@ -390,11 +390,11 @@ This is useful for maintaining and referencing sample code variants in their nat
390390

391391
#### Include specific files from the same directory
392392

393-
> [!Caution]
393+
> \[!Caution]
394394
> **Don't use for code examples**
395395
> Using this and `get-shared-text` shortcodes to include code examples prevents the code from being tested.
396396

397-
To include the text from one file in another file in the same directory, use the `{{< get-leaf-text >}}` shortcode. The directory that contains both files must be a Hugo [_Leaf Bundle_](https://gohugo.io/content-management/page-bundles/#leaf-bundles), a directory that doesn't have any child directories.
397+
To include the text from one file in another file in the same directory, use the `{{< get-leaf-text >}}` shortcode. The directory that contains both files must be a Hugo [*Leaf Bundle*](https://gohugo.io/content-management/page-bundles/#leaf-bundles), a directory that doesn't have any child directories.
398398

399399
In the following example, `api` is a leaf bundle. `content` isn't.
400400

@@ -447,13 +447,13 @@ Each children list `type` uses frontmatter properties when generating the list o
447447

448448
| Frontmatter | articles | list | functions |
449449
| :------------------- | :------: | :--: | :-------: |
450-
| `list_title` | ✓ | | ✓ |
451-
| `description` | | | |
452-
| `external_url` | ✓ | | |
453-
| `list_image` | | | |
454-
| `list_note` | | | |
455-
| `list_code_example` | | | |
456-
| `list_query_example` | | | |
450+
| `list_title` | ✓ | | ✓ |
451+
| `description` | | | |
452+
| `external_url` | ✓ | | |
453+
| `list_image` | | | |
454+
| `list_note` | | | |
455+
| `list_code_example` | | | |
456+
| `list_query_example` | | | |
457457

458458
## Visual Elements
459459

@@ -695,7 +695,7 @@ Column 2
695695

696696
The following options are available:
697697

698-
- half _(Default)_
698+
- half *(Default)*
699699
- third
700700
- quarter
701701

@@ -721,10 +721,10 @@ Click {{< caps >}}Add Data{{< /caps >}}
721721

722722
### Authentication token link
723723

724-
Use the `{{% token-link "<descriptor>" "<link_append>%}}` shortcode to automatically generate links to token management documentation. The shortcode accepts two _optional_ arguments:
724+
Use the `{{% token-link "<descriptor>" "<link_append>%}}` shortcode to automatically generate links to token management documentation. The shortcode accepts two *optional* arguments:
725725

726726
- **descriptor**: An optional token descriptor
727-
- **link_append**: An optional path to append to the token management link path, `/<product>/<version>/admin/tokens/`.
727+
- **link\_append**: An optional path to append to the token management link path, `/<product>/<version>/admin/tokens/`.
728728

729729
```md
730730
{{% token-link "database" "resource/" %}}
@@ -775,7 +775,7 @@ Descriptions should follow consistent patterns:
775775
- Recommended: "your {{% token-link "database" %}}"{{% show-in "enterprise" %}} with permissions on the specified database{{% /show-in %}}
776776
- Avoid: "your token", "the token", "an authorization token"
777777
3. **Database names**:
778-
- Recommended: "the name of the database to [action]"
778+
- Recommended: "the name of the database to \[action]"
779779
- Avoid: "your database", "the database name"
780780
4. **Conditional content**:
781781
- Use `{{% show-in "enterprise" %}}` for content specific to enterprise versions
@@ -797,13 +797,75 @@ Descriptions should follow consistent patterns:
797797

798798
#### Syntax
799799

800-
- `{ placeholders="PATTERN1|PATTERN2" }`: Use this code block attribute to define placeholder patterns
800+
- `{ placeholders="PATTERN1|PATTERN2" }`: Use this code block attribute to define placeholder patterns
801801
- `{{% code-placeholder-key %}}`: Use this shortcode to define a placeholder key
802802
- `{{% /code-placeholder-key %}}`: Use this shortcode to close the key name
803803

804-
_The `placeholders` attribute supercedes the deprecated `code-placeholders` shortcode._
804+
*The `placeholders` attribute supercedes the deprecated `code-placeholders` shortcode.*
805+
806+
#### Automated placeholder syntax
807+
808+
Use the `docs placeholders` command to automatically add placeholder syntax to code blocks and descriptions:
809+
810+
```bash
811+
# Process a file
812+
npx docs placeholders content/influxdb3/core/admin/upgrade.md
813+
814+
# Preview changes without modifying the file
815+
npx docs placeholders content/influxdb3/core/admin/upgrade.md --dry
816+
817+
# Get help
818+
npx docs placeholders --help
819+
```
820+
821+
**What it does:**
822+
823+
1. Detects UPPERCASE placeholders in code blocks
824+
2. Adds `{ placeholders="..." }` attribute to code fences
825+
3. Wraps placeholder descriptions with `{{% code-placeholder-key %}}` shortcodes
826+
827+
**Example transformation:**
828+
829+
Before:
830+
831+
````markdown
832+
```bash
833+
influxdb3 query \
834+
--database SYSTEM_DATABASE \
835+
--token ADMIN_TOKEN \
836+
"SELECT * FROM system.version"
837+
```
838+
839+
Replace the following:
840+
841+
- **`SYSTEM_DATABASE`**: The name of your system database
842+
- **`ADMIN_TOKEN`**: An admin token with read permissions
843+
````
844+
845+
After:
846+
847+
````markdown
848+
```bash { placeholders="ADMIN_TOKEN|SYSTEM_DATABASE" }
849+
influxdb3 query \
850+
--database SYSTEM_DATABASE \
851+
--token ADMIN_TOKEN \
852+
"SELECT * FROM system.version"
853+
```
854+
855+
Replace the following:
856+
857+
- {{% code-placeholder-key %}}`SYSTEM_DATABASE`{{% /code-placeholder-key %}}: The name of your system database
858+
- {{% code-placeholder-key %}}`ADMIN_TOKEN`{{% /code-placeholder-key %}}: An admin token with read permissions
859+
````
860+
861+
**How it works:**
862+
863+
- Pattern: Matches words with 2+ characters, all uppercase, can include underscores
864+
- Excludes common words: HTTP verbs (GET, POST), protocols (HTTP, HTTPS), SQL keywords (SELECT, FROM), etc.
865+
- Idempotent: Running multiple times won't duplicate syntax
866+
- Preserves existing `placeholders` attributes and already-wrapped descriptions
805867

806-
#### Example usage
868+
#### Manual placeholder usage
807869

808870
```sh { placeholders "DATABASE_NAME|USERNAME|PASSWORD_OR_TOKEN|API_TOKEN|[email protected]" }
809871
curl --request POST http://localhost:8086/write?db=DATABASE_NAME \
@@ -839,7 +901,7 @@ Sample dataset to output. Use either `set` argument name or provide the set as t
839901

840902
#### includeNull
841903

842-
Specify whether or not to include _null_ values in the dataset. Use either `includeNull` argument name or provide the boolean value as the second argument.
904+
Specify whether or not to include *null* values in the dataset. Use either `includeNull` argument name or provide the boolean value as the second argument.
843905

844906
#### includeRange
845907

@@ -1115,6 +1177,6 @@ The InfluxDB host placeholder that gets replaced by custom domains differs betwe
11151177
{{< influxdb/host "serverless" >}}
11161178
```
11171179
1118-
---
1180+
***
11191181
11201182
**For working examples**: Test all shortcodes in [content/example.md](content/example.md)

README.md

Lines changed: 53 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<img src="/static/img/influx-logo-cubo-dark.png" width="200">
33
</p>
44

5-
# InfluxDB 2.0 Documentation
5+
# InfluxData Product Documentation
66

7-
This repository contains the InfluxDB 2.x documentation published at [docs.influxdata.com](https://docs.influxdata.com).
7+
This repository contains the InfluxData product documentation for InfluxDB and related tooling published at [docs.influxdata.com](https://docs.influxdata.com).
88

99
## Contributing
1010

@@ -15,6 +15,26 @@ For information about contributing to the InfluxData documentation, see [Contrib
1515

1616
For information about testing the documentation, including code block testing, link validation, and style linting, see [Testing guide](DOCS-TESTING.md).
1717

18+
## Documentation Tools
19+
20+
This repository includes a `docs` CLI tool for common documentation workflows:
21+
22+
```sh
23+
# Create new documentation from a draft
24+
npx docs create drafts/new-feature.md --products influxdb3_core
25+
26+
# Edit existing documentation from a URL
27+
npx docs edit https://docs.influxdata.com/influxdb3/core/admin/
28+
29+
# Add placeholder syntax to code blocks
30+
npx docs placeholders content/influxdb3/core/admin/upgrade.md
31+
32+
# Get help
33+
npx docs --help
34+
```
35+
36+
The `docs` command is automatically configured when you run `yarn install`.
37+
1838
## Documentation
1939

2040
Comprehensive reference documentation for contributors:
@@ -27,6 +47,7 @@ Comprehensive reference documentation for contributors:
2747
- **[API Documentation](api-docs/README.md)** - API reference generation
2848

2949
### Quick Links
50+
3051
- [Style guidelines](DOCS-CONTRIBUTING.md#style-guidelines)
3152
- [Commit guidelines](DOCS-CONTRIBUTING.md#commit-guidelines)
3253
- [Code block testing](DOCS-TESTING.md#code-block-testing)
@@ -35,42 +56,49 @@ Comprehensive reference documentation for contributors:
3556

3657
InfluxData takes security and our users' trust very seriously.
3758
If you believe you have found a security issue in any of our open source projects,
38-
please responsibly disclose it by contacting [email protected].
59+
please responsibly disclose it by contacting <[email protected]>.
3960
More details about security vulnerability reporting,
40-
including our GPG key, can be found at https://www.influxdata.com/how-to-report-security-vulnerabilities/.
61+
including our GPG key, can be found at <https://www.influxdata.com/how-to-report-security-vulnerabilities/>.
4162

4263
## Running the docs locally
4364

4465
1. [**Clone this repository**](https://help.github.com/articles/cloning-a-repository/) to your local machine.
4566

46-
2. **Install NodeJS, Yarn, Hugo, & Asset Pipeline Tools**
67+
2. **Install NodeJS, Yarn, Hugo, & Asset Pipeline Tools**
68+
69+
The InfluxData documentation uses [Hugo](https://gohugo.io/), a static site generator built in Go. The site uses Hugo's asset pipeline, which requires the extended version of Hugo along with NodeJS tools like PostCSS, to build and process stylesheets and JavaScript.
4770

48-
The InfluxData documentation uses [Hugo](https://gohugo.io/), a static site generator built in Go. The site uses Hugo's asset pipeline, which requires the extended version of Hugo along with NodeJS tools like PostCSS, to build and process stylesheets and JavaScript.
71+
To install the required dependencies and build the assets, do the following:
4972

50-
To install the required dependencies and build the assets, do the following:
73+
1. [Install NodeJS](https://nodejs.org/en/download/)
74+
2. [Install Yarn](https://classic.yarnpkg.com/en/docs/install/)
75+
3. In your terminal, from the `docs-v2` directory, install the dependencies:
5176

52-
1. [Install NodeJS](https://nodejs.org/en/download/)
53-
2. [Install Yarn](https://classic.yarnpkg.com/en/docs/install/)
54-
3. In your terminal, from the `docs-v2` directory, install the dependencies:
77+
```sh
78+
cd docs-v2
79+
yarn install
80+
```
81+
82+
***Note:** The most recent version of Hugo tested with this documentation is **0.149.0**.*
5583

56-
```sh
57-
cd docs-v2
58-
yarn install
59-
```
84+
After installation, the `docs` command will be available via `npx`:
6085

61-
_**Note:** The most recent version of Hugo tested with this documentation is **0.149.0**._
86+
```sh
87+
npx docs --help
88+
```
6289

6390
3. To generate the API docs, see [api-docs/README.md](api-docs/README.md).
6491

65-
4. **Start the Hugo server**
92+
4. **Start the Hugo server**
6693

67-
Hugo provides a local development server that generates the HTML pages, builds the static assets, and serves them at `localhost:1313`.
94+
Hugo provides a local development server that generates the HTML pages, builds the static assets, and serves them at `localhost:1313`.
6895

69-
In your terminal, start the Hugo server:
96+
In your terminal, start the Hugo server:
97+
98+
```sh
99+
npx hugo server
100+
```
70101

71-
```sh
72-
npx hugo server
73-
```
74102
5. View the docs at [localhost:1313](http://localhost:1313).
75103

76104
### Alternative: Use docker compose
@@ -81,7 +109,8 @@ including our GPG key, can be found at https://www.influxdata.com/how-to-report-
81109

82110
3. Use Docker Compose to start the Hugo server in development mode--for example, enter the following command in your terminal:
83111

84-
```sh
85-
docker compose up local-dev
86-
```
112+
```sh
113+
docker compose up local-dev
114+
```
115+
87116
4. View the docs at [localhost:1313](http://localhost:1313).

0 commit comments

Comments
 (0)