Skip to content

Commit 84ba01d

Browse files
authored
docs: Add GitHib copilot instruction files (#2146)
<!-- CURSOR_SUMMARY --> > [!NOTE] > Adds `.github/copilot-instructions.md` detailing repo-specific context and writing guidelines for AI tools (OpenAPI pipeline, theme, patterns, QA, and style). > > - **Docs**: > - **New AI agent guide** in `.github/copilot-instructions.md` providing: > - **Project overview & architecture**: Docusaurus multi-repo setup, custom theme workspace. > - **OpenAPI build pipeline**: source locations, Redocly plugins, build command, generated outputs. > - **Project patterns**: OpenAPI code samples, slug collection, external link processing, LLMs.txt generation. > - **Quality & pitfalls**: broken links, frontmatter, code block languages; local build, linting, OpenAPI validation. > - **Quick reference** for common tasks and navigation updates. > - **Writing & style guidelines**: frontmatter schema, naming, formatting, admonitions, terminology. > - **Content review checklist** and **doc type guidelines**; related references (`CONTRIBUTING.md`, `AGENTS.md`). > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 8c34a1b. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 4f2dc6d commit 84ba01d

1 file changed

Lines changed: 200 additions & 0 deletions

File tree

.github/copilot-instructions.md

Lines changed: 200 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,200 @@
1+
# Apify Documentation - AI Agent Guide
2+
3+
## Part 1: Repository-Specific Information
4+
5+
### Project Overview
6+
7+
Docusaurus-based documentation site combining:
8+
9+
- **Platform docs** (`/sources/platform/`) - Product documentation
10+
- **Academy** (`/sources/academy/`) - Educational courses
11+
- **API reference** (`/apify-api/`) - Generated from OpenAPI specs
12+
- **Multi-repo architecture** - SDK/Client docs from separate repos served via nginx
13+
14+
**Key insight:** ONE unified site built from MULTIPLE repositories. See CONTRIBUTING.md for multi-repo setup.
15+
16+
### Architecture & Critical Workflows
17+
18+
#### OpenAPI Documentation Build Pipeline
19+
20+
**Critical:** API docs are generated, NOT hand-written. The workflow:
21+
22+
1. **Source of truth**: `apify-api/openapi/openapi.yaml` (splits into `/paths` and `/components`)
23+
2. **Redocly plugins** (`apify-api/plugins/apify.mjs`) inject custom behavior:
24+
25+
- `code-samples-decorator.mjs` - Auto-adds code samples if files exist in `/code_samples/{js,curl}/`
26+
- `legacy-doc-url-decorator.mjs` - Adds backward-compatible URLs
27+
- `client-references-links-decorator.mjs` - Links to client library docs
28+
29+
3. **Build command**: `npm run api:rebuild` = clean + bundle with Redocly + generate with Docusaurus
30+
4. **Output**: Markdown files in `apify-api/docs/` (gitignored, regenerated on each build)
31+
32+
**Never edit generated files directly**. Edit the OpenAPI YAML or add code samples to trigger auto-inclusion.
33+
34+
#### Custom Theme System
35+
36+
Shared theme in `apify-docs-theme/` workspace:
37+
38+
- Single source of truth for navigation, styling, components
39+
- Used across all 6+ documentation repos
40+
- Changes here propagate via CI to all projects
41+
- Key files: `src/config.js` (nav structure), `src/theme.js` (Docusaurus theme config)
42+
43+
### Project-Specific Patterns
44+
45+
#### OpenAPI Code Samples
46+
47+
Add code samples by creating files in `apify-api/openapi/code_samples/{javascript,curl}/`:
48+
49+
- Filename MUST match `operationId` from OpenAPI spec
50+
- Example: `actorRun_get.js` for operation with `operationId: "actorRun_get"`
51+
- Decorator auto-detects and adds `x-codeSamples` property
52+
- Missing samples logged during build (check console)
53+
54+
#### Slug Collection Pattern
55+
56+
`tools/utils/collectSlugs.js` recursively scans directories for `slug:` in frontmatter. Used in `docusaurus.config.js` to build dynamic navigation with `activeBaseRegex` patterns. When adding new sections, ensure slugs are collected for nav highlighting.
57+
58+
#### External Link Processing
59+
60+
`tools/utils/externalLink.js` rehype plugin auto-adds `target="_blank"` and `rel="noopener noreferrer"` to external links. Internal links (same domain) are detected via `isInternal()` helper.
61+
62+
#### LLMs.txt Generation
63+
64+
Post-build (`scripts/joinLlmsFiles.mjs` + `indentLlmsFile.mjs`):
65+
66+
- Combines `llms.txt` from all sections into root
67+
- Used by AI tools for context (via `@signalwire/docusaurus-plugin-llms-txt`)
68+
- Edit source `llms.txt` files in content dirs, not the generated root one
69+
70+
### Common Pitfalls
71+
72+
1. **Editing generated API docs** - Always edit OpenAPI YAML source, never generated markdown
73+
2. **Broken links on build** - `onBrokenLinks: 'throw'` fails CI. Check slugs match file paths
74+
3. **Missing frontmatter** - Description or slug errors break SEO and navigation
75+
4. **Missing code block language** - Always specify language for syntax highlighting
76+
77+
### Testing & Quality
78+
79+
- **Local build test**: `npm run build` - Catches broken links, bad frontmatter
80+
- **Linting**: `npm run lint:fix` - Auto-fixes markdown + code style issues
81+
- **Link validation**: Docusaurus throws on broken internal links (see `onBrokenLinks` in config)
82+
- **OpenAPI validation**: `npm run redoc:test` - Validates OpenAPI spec with Redocly
83+
84+
### Quick Reference
85+
86+
- **Add new doc**: Create `.md` in `/sources/{platform,academy}/`, add frontmatter with title/description/slug
87+
- **Add API endpoint**: Edit `/apify-api/openapi/paths/**/*.yaml`, add code samples, run `npm run api:rebuild`
88+
- **Update navigation**: Edit `/sources/{platform,academy}/sidebars.js`
89+
- **Fix broken build**: Check `onBrokenLinks` errors, verify slugs match file paths, validate frontmatter
90+
91+
## Part 2: Writing & Style Guidelines
92+
93+
### Content Standards (Microsoft Style Guide Based)
94+
95+
#### Frontmatter Requirements
96+
97+
Every `.md`/`.mdx` file needs:
98+
99+
```yaml
100+
---
101+
title: "Sentence case title (action-oriented)"
102+
description: "140-160 chars - explain value, not features"
103+
sidebar_position: 1
104+
slug: /path/to/page
105+
---
106+
```
107+
108+
#### File Naming & Organization
109+
110+
- **Kebab-case filenames**: `web-scraping-basics.md` (never camelCase or snake_case)
111+
- **Match slug to file path**: `/sources/platform/actors/running.md``slug: /platform/actors/running`
112+
113+
#### Text Formatting Conventions
114+
115+
- **Bold** for UI elements, buttons, tabs, menu items only: "Click **Save & Run**". Never use bold for emphasis.
116+
- *Italics* for emphasis (use sparingly)
117+
- `code` for inline code, file paths, API parameters: "Set `timeout` in `INPUT.json`"
118+
- Code blocks MUST specify language: ` ```javascript `, ` ```python `, ` ```bash `
119+
- Use [code tabs](https://docusaurus.io/docs/markdown-features/tabs) for multi-language examples
120+
121+
#### Writing Style
122+
123+
- Use simple English - prefer "use" over "utilize", favor simple sentence structures
124+
- Use American English spelling: "color" not "colour"
125+
- Use Oxford commas in lists
126+
- Use sentence case for headings and titles (not title case)
127+
- **Never make assumptions about product features** - ask if unsure
128+
129+
#### Admonitions (Docusaurus-specific)
130+
131+
**All admonitions must have a title.** Available types: `note`, `tip`, `info`, `caution`, `danger`
132+
133+
```markdown
134+
:::note Important information
135+
136+
Standard informational note.
137+
138+
:::
139+
140+
:::tip Pro tip
141+
142+
Helpful advice for advanced users.
143+
144+
:::
145+
146+
:::caution Warning
147+
148+
Something that could cause issues.
149+
150+
:::
151+
```
152+
153+
#### Terminology & Word List
154+
155+
Use exact capitalization and phrasing:
156+
157+
- **Apify Actor** (never "Apify actor")
158+
- **Apify Proxy**
159+
- **Apify Console** (never "the Apify Console")
160+
- **Apify Store** (never "the Apify Store")
161+
- **the Apify team**
162+
- **the Apify platform**
163+
- **AI agent**, **MCP server** (lowercase for generic terms)
164+
165+
### Content Review Checklist
166+
167+
When reviewing or creating documentation:
168+
169+
- **Clarity**: Instructions are easy to understand
170+
- **Consistency**: Uniform terminology (see word list above) and style throughout
171+
- **Grammar & Spelling**: Correct errors, use American English
172+
- **Structure**: Logical flow, no duplicate content, appropriate headings/lists
173+
- **Links**: Verify all links are functional and relevant, link key terms to their docs
174+
- **Code snippets**: Developer-provided; check comments and obvious mistakes only
175+
176+
### Documentation Type Guidelines
177+
178+
**Platform documentation** (`sources/platform/**/*.md`):
179+
180+
- Focus on practical, actionable guidance
181+
- Include real-world examples and use cases
182+
- Reference related API endpoints when applicable
183+
184+
**Academy content** (`sources/academy/**/*.md`):
185+
186+
- Structure content for learning progression
187+
- Include hands-on exercises and examples
188+
- Provide clear prerequisites and next steps
189+
190+
**MDX files** (`sources/**/*.mdx`):
191+
192+
- Use component imports and JSX syntax appropriately
193+
- Ensure proper frontmatter formatting
194+
- Test component rendering during development
195+
196+
## Related Documentation
197+
198+
- Full contribution guide: `CONTRIBUTING.md`
199+
- Style standards: `AGENTS.md` (vendor-agnostic rules)
200+
- Cursor-specific rules: `.cursor/rules/*.mdc` (if using Cursor)

0 commit comments

Comments
 (0)