Skip to content

Commit 0c16330

Browse files
authored
Add AGENTS.md and CLAUDE.md to the project (#1439)
I've been using AI coding agents to assist my development in RDoc for a while. And having these instructions can save me (or anyone who wants to contribute) quite a bit of time. `AGENTS.md` is what most agentic tools use, such as OpenAI Codex or Cursor. `CLAUDE.md` is only for Claude Code, which is the main tool I use.
1 parent c03a250 commit 0c16330

File tree

3 files changed

+240
-0
lines changed

3 files changed

+240
-0
lines changed

.rdoc_options

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ title: rdoc Documentation
33
main_page: README.md
44
autolink_excluded_words:
55
- RDoc
6+
7+
exclude:
8+
- AGENTS.md
9+
- CLAUDE.md
10+
- lib/rdoc/markdown.kpeg

AGENTS.md

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# RDoc Project Guide for AI Agents
2+
3+
## Project Overview
4+
5+
**RDoc** is Ruby's default documentation generation tool that produces HTML and command-line documentation for Ruby projects. It parses Ruby source code, C extensions, and markup files to generate documentation.
6+
7+
- **Repository:** https://github.com/ruby/rdoc
8+
- **Homepage:** https://ruby.github.io/rdoc
9+
- **Required Ruby:** See the version specified in gemspec
10+
- **Main Executables:** `rdoc` and `ri`
11+
12+
## Key Development Commands
13+
14+
### Testing
15+
16+
```bash
17+
# Run all tests (default task)
18+
bundle exec rake
19+
20+
# Run unit tests only (excludes RubyGems integration)
21+
bundle exec rake normal_test
22+
23+
# Run RubyGems integration tests only
24+
bundle exec rake rubygems_test
25+
26+
# Verify generated parser files are current (CI check)
27+
bundle exec rake verify_generated
28+
```
29+
30+
**Test Framework:** Test::Unit with `test-unit` gem
31+
**Test Location:** `test/` directory
32+
**Test Helper:** `test/lib/helper.rb`
33+
34+
### Linting
35+
36+
#### RuboCop (Ruby Linting)
37+
38+
```bash
39+
# Check Ruby code style
40+
bundle exec rubocop
41+
42+
# Auto-fix style issues
43+
bundle exec rubocop -A
44+
```
45+
46+
**Configuration:** `.rubocop.yml`
47+
48+
- Target Ruby: 3.0
49+
- Minimal cop set (opt-in approach)
50+
- Excludes generated parser files
51+
52+
#### Herb Linter (ERB/RHTML Files)
53+
54+
```bash
55+
# Lint ERB template files
56+
npx @herb-tools/linter "**/*.rhtml"
57+
58+
# Lint specific directory
59+
npx @herb-tools/linter "lib/**/*.rhtml"
60+
```
61+
62+
**Template Location:** `lib/rdoc/generator/template/**/*.rhtml`
63+
**CI Workflow:** `.github/workflows/lint.yml`
64+
65+
### Documentation Generation
66+
67+
```bash
68+
# Generate documentation (creates _site directory)
69+
bundle exec rake rdoc
70+
71+
# Force regenerate documentation
72+
bundle exec rake rerdoc
73+
74+
# Show documentation coverage
75+
bundle exec rake rdoc:coverage
76+
bundle exec rake coverage
77+
```
78+
79+
**Output Directory:** `_site/` (GitHub Pages compatible)
80+
**Configuration:** `.rdoc_options`
81+
82+
### Parser Generation
83+
84+
RDoc uses generated parsers for Markdown and RD formats:
85+
86+
```bash
87+
# Generate all parser files from sources
88+
bundle exec rake generate
89+
90+
# Remove generated parser files
91+
bundle exec rake clean
92+
```
93+
94+
**Generated Files:**
95+
96+
- `lib/rdoc/rd/block_parser.rb` (from `.ry` via racc)
97+
- `lib/rdoc/rd/inline_parser.rb` (from `.ry` via racc)
98+
- `lib/rdoc/markdown.rb` (from `.kpeg` via kpeg)
99+
- `lib/rdoc/markdown/literals.rb` (from `.kpeg` via kpeg)
100+
101+
**Note:** These files are auto-generated and should not be edited manually. Always regenerate after modifying source `.ry` or `.kpeg` files.
102+
103+
### Building and Releasing
104+
105+
```bash
106+
# Build gem package
107+
bundle exec rake build
108+
109+
# Install gem locally
110+
bundle exec rake install
111+
112+
# Create tag and push to rubygems.org
113+
bundle exec rake release
114+
```
115+
116+
## Project Structure
117+
118+
```sh
119+
lib/rdoc/
120+
├── rdoc.rb # Main entry point (RDoc::RDoc class)
121+
├── version.rb # Version constant
122+
├── task.rb # Rake task integration
123+
├── parser/ # Source code parsers (Ruby, C, Markdown, RD)
124+
│ ├── ruby.rb # Ruby code parser
125+
│ ├── c.rb # C extension parser
126+
│ ├── prism_ruby.rb # Prism-based Ruby parser
127+
│ └── ...
128+
├── generator/ # Documentation generators
129+
│ ├── darkfish.rb # HTML generator (default theme)
130+
│ ├── markup.rb # Markup format generator
131+
│ ├── ri.rb # RI command generator
132+
│ └── template/darkfish/ # ERB templates (.rhtml files)
133+
├── markup/ # Markup parsing and formatting
134+
├── code_object/ # AST objects for documented items
135+
├── markdown/ # Markdown parsing
136+
├── rd/ # RD format parsing
137+
└── ri/ # RI (Ruby Info) tool
138+
139+
test/ # 79 test files
140+
├── lib/helper.rb # Test helpers
141+
└── rdoc/ # Main test directory
142+
143+
exe/
144+
├── rdoc # rdoc command executable
145+
└── ri # ri command executable
146+
```
147+
148+
## Important Files
149+
150+
### Configuration
151+
152+
- `.rubocop.yml` - RuboCop configuration (main)
153+
- `.generated_files_rubocop.yml` - RuboCop config for generated files
154+
- `.rdoc_options` - RDoc generation options
155+
- `.document` - File list for documentation
156+
- `Rakefile` - Task definitions
157+
- `lib/rdoc/task.rb` - Task definitions provided by RDoc
158+
- `rdoc.gemspec` - Gem specification
159+
- `Gemfile` - Development dependencies
160+
161+
### CI/CD
162+
163+
- `.github/workflows/test.yml` - Test execution across Ruby versions/platforms
164+
- `.github/workflows/lint.yml` - Linting (RuboCop + Herb)
165+
- `.github/workflows/push_gem.yml` - Gem publishing
166+
167+
### Documentation
168+
169+
- `README.md` - Basic usage guide
170+
- `ExampleRDoc.rdoc` - RDoc markup examples
171+
- `doc/rdoc/markup_reference.rb` - RDoc markup references
172+
- `ExampleMarkdown.md` - Markdown examples
173+
174+
## Architecture Notes
175+
176+
### Pluggable System
177+
178+
- **Parsers:** Ruby, C, Markdown, RD, Prism-based Ruby (experimental)
179+
- **Generators:** HTML/Darkfish, RI, POT (gettext), JSON, Markup
180+
181+
## Common Workflows
182+
183+
Do NOT commit anything. Ask the developer to review the changes after tasks are finished.
184+
185+
NEVER pushes code to any repositories.
186+
187+
### Making Code Changes
188+
189+
Use Red, Green, Refactor approach:
190+
191+
1. **Ensure Ruby version**: Verify you're using Ruby 3.3.0+ (prepend `chruby <ruby version>` if needed)
192+
2. **Red - Write failing tests**: Add tests that fail for the new behavior
193+
3. **Verify failure**: Run `bundle exec rake` to confirm tests fail as expected
194+
4. **Green - Make it work**: Implement the minimum code to make tests pass
195+
5. **Refactor - Make it right**: Improve code quality while keeping tests green
196+
- Run `bundle exec rake` after each refactor to ensure tests still pass
197+
- Iterate on steps 4-5 as needed
198+
6. **Lint your changes**:
199+
- Ruby code: `bundle exec rubocop -A` (auto-fix when possible)
200+
- ERB templates: `npx @herb-tools/linter "**/*.rhtml"` (if modified)
201+
202+
### Modifying Parsers
203+
204+
1. Edit source files (`.ry` or `.kpeg`)
205+
2. Regenerate: `bundle exec rake generate`
206+
3. Verify: `bundle exec rake verify_generated`
207+
4. Run tests: `bundle exec rake`
208+
209+
### Updating Documentation
210+
211+
1. Modify documentation comments in source
212+
2. Regenerate: `bundle exec rake rerdoc`
213+
3. Check output in `_site/` directory
214+
4. Check coverage: `bundle exec rake coverage`
215+
216+
## Notes for AI Agents
217+
218+
1. **Always run tests** after making changes: `bundle exec rake`
219+
2. **Check both RuboCop and Herb** for linting
220+
3. **Regenerate parsers** if you modify `.ry` or `.kpeg` files
221+
4. **Use `rake rerdoc`** to regenerate documentation (not just `rdoc`)
222+
5. **Verify generated files** with `rake verify_generated`
223+
6. **Don't edit generated files** directly (in `lib/rdoc/markdown/` and `lib/rdoc/rd/`)

CLAUDE.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Claude Code Instructions for RDoc
2+
3+
Please refer to `AGENTS.md` for comprehensive project documentation, including:
4+
5+
- Rake tasks and workflows
6+
- Testing setup
7+
- Linting configuration
8+
- Project structure
9+
- Development commands
10+
- CI/CD information
11+
12+
All project-specific instructions and guidelines are maintained in `AGENTS.md`.

0 commit comments

Comments
 (0)