|
| 1 | +# Create an API Overview File for This Julia Package |
| 2 | + |
| 3 | +Please generate an API overview document for this Julia package that will serve both human users and AI assistants. Follow the structure and guidelines below. |
| 4 | + |
| 5 | +## Step 1: Create an API Overview File |
| 6 | + |
| 7 | +Create a file named `api.md` in the root directory of your package: |
| 8 | + |
| 9 | +``` |
| 10 | +YourPackage/ |
| 11 | +├── src/ |
| 12 | +├── test/ |
| 13 | +├── docs/ |
| 14 | +├── Project.toml |
| 15 | +├── README.md |
| 16 | +└── api.md <- Create this file |
| 17 | +``` |
| 18 | + |
| 19 | +This file should contain a concise, structured overview of your package's API with examples. Organize it with clear markdown headings (use ## for sections). |
| 20 | + |
| 21 | +## Why Create an API Overview? |
| 22 | + |
| 23 | +### For Humans |
| 24 | +- Provides a **concise reference** without diving into full documentation |
| 25 | +- Offers **quick-start examples** for common use cases |
| 26 | +- Shows **relevant patterns** more clearly than individual docstrings |
| 27 | +- Creates an **at-a-glance understanding** of package capabilities |
| 28 | +- Complements detailed documentation with a **higher-level view** |
| 29 | + |
| 30 | +### For AI Assistants |
| 31 | +- Enables **better code generation** with correct API patterns |
| 32 | +- Provides **structured context** about type hierarchies and relationships |
| 33 | +- Offers **consistent examples** to learn from when generating code |
| 34 | +- Creates **clear patterns** to follow when suggesting package usage |
| 35 | +- Helps avoid **common pitfalls** or misunderstandings about the API |
| 36 | + |
| 37 | +## What to Include in Your API Overview |
| 38 | + |
| 39 | +### 1. Key Concepts |
| 40 | +- Brief explanation of the core concepts and terminology |
| 41 | +- Domain-specific information necessary to understand the API |
| 42 | +- Important conventions (units, coordinate systems, defaults) |
| 43 | + |
| 44 | +### 2. Type Hierarchy |
| 45 | +- Visual representation of main types and their relationships |
| 46 | +- Clear indication of abstract vs. concrete types |
| 47 | +- Type parameters and their meaning |
| 48 | + |
| 49 | +### 3. Essential Types |
| 50 | +- Type definitions for most important types |
| 51 | +- Field documentation with types and purpose |
| 52 | +- Comments on mutable vs. immutable choices |
| 53 | + |
| 54 | +### 4. Constructor Examples |
| 55 | +- Common ways to instantiate key types |
| 56 | +- Parameter patterns and naming conventions |
| 57 | +- Default values and optional parameters |
| 58 | + |
| 59 | +### 5. Core Functions |
| 60 | +- Main functions grouped by purpose |
| 61 | +- Input/output patterns |
| 62 | +- Common parameter combinations |
| 63 | + |
| 64 | +### 6. Common Workflows |
| 65 | +- Step-by-step examples of typical usage patterns |
| 66 | +- Multiple approaches to solving common problems |
| 67 | +- Integration examples showing how components work together |
| 68 | + |
| 69 | +### 7. Complete Examples |
| 70 | +- Full working examples demonstrating end-to-end usage |
| 71 | +- Comments explaining each step |
| 72 | +- Sample output where appropriate |
| 73 | + |
| 74 | +## Writing Style Best Practices |
| 75 | + |
| 76 | +1. **Be Concise**: Prioritize brevity and clarity over exhaustive coverage |
| 77 | +2. **Use Consistent Formatting**: Maintain consistent structure for similar items |
| 78 | +3. **Focus on Patterns**: Highlight patterns that can be generalized |
| 79 | +4. **Include Type Information**: Make types explicit in examples and descriptions |
| 80 | +5. **Comment Liberally**: Include comments in code examples explaining parameter purposes |
| 81 | +6. **Use Clear Section Headers**: Make the document easily scannable with descriptive headers |
| 82 | +7. **Show Don't Tell**: Prefer concrete examples over abstract descriptions |
| 83 | +8. **Include Important Gotchas**: Note common pitfalls or non-obvious behaviors |
| 84 | + |
| 85 | +## Formatting Guidelines |
| 86 | + |
| 87 | +### Markdown Structure |
| 88 | +- Use `#` for title |
| 89 | +- Use `##` for main sections |
| 90 | +- Use `###` for subsections |
| 91 | +- Use backticks for inline code |
| 92 | +- Use triple backticks for code blocks with language specifier |
| 93 | +- Use bold (`**text**`) for important concepts |
| 94 | + |
| 95 | +### Code Examples |
| 96 | +- Always specify the language for code blocks: ```julia |
| 97 | +- Use descriptive variable names |
| 98 | +- Include comments for non-obvious steps |
| 99 | +- Show both simple and complex cases |
| 100 | +- Align similar elements for readability |
| 101 | +- Include complete function calls with all parameters |
| 102 | + |
| 103 | +### Type Definitions |
| 104 | +- Include complete type definitions with field comments |
| 105 | +- Show type parameters explicitly |
| 106 | +- Indicate mutability clearly |
| 107 | + |
| 108 | +## Example Section: "Filtering Operations" |
| 109 | + |
| 110 | +Here's an example of how you might document filtering operations in your package: |
| 111 | + |
| 112 | +When writing your actual Markdown, you would use the following structure: |
| 113 | + |
| 114 | +- A level-2 heading: `## Filtering Operations` |
| 115 | +- A Julia code block (with triple backticks and "julia" language specifier) |
| 116 | +- Code examples with comments |
| 117 | +- A brief explanation text |
| 118 | +- A numbered list explaining key points |
| 119 | + |
| 120 | +Your code examples would look like this: |
| 121 | + |
| 122 | +```julia |
| 123 | +# Filter by emitter properties using @filter macro |
| 124 | +bright = @filter(smld, photons > 1000) |
| 125 | +precise = @filter(smld, σ_x < 0.02 && σ_y < 0.02) |
| 126 | +combined = @filter(smld, photons > 1000 && σ_x < 0.02) |
| 127 | + |
| 128 | +# Select frames |
| 129 | +frame_5 = filter_frames(smld, 5) # Single frame |
| 130 | +early_frames = filter_frames(smld, 1:10) # Range of frames |
| 131 | +specific_frames = filter_frames(smld, [1,3,5,7]) # Specific frames |
| 132 | + |
| 133 | +# Select region of interest (ROI) |
| 134 | +# 2D ROI |
| 135 | +roi_2d = filter_roi(smld, 1.0:5.0, 2.0:6.0) # x_range, y_range |
| 136 | + |
| 137 | +# 3D ROI (for 3D emitters only) |
| 138 | +roi_3d = filter_roi(smld, 1.0:5.0, 2.0:6.0, -1.0:1.0) # x_range, y_range, z_range |
| 139 | +``` |
| 140 | + |
| 141 | +Then follow with explanatory text like: |
| 142 | + |
| 143 | +"The package provides several approaches to filtering data: |
| 144 | + |
| 145 | +1. The `@filter` macro allows filtering by any emitter property using natural condition syntax |
| 146 | +2. `filter_frames` selects emitters from specific frames efficiently |
| 147 | +3. `filter_roi` selects emitters within spatial regions of interest" |
| 148 | + |
| 149 | +## Maintenance Tips |
| 150 | + |
| 151 | +1. **Update with API Changes**: Keep the overview in sync with API changes |
| 152 | +2. **Focus on Stability**: Emphasize stable, public API features |
| 153 | +3. **Revise Examples**: Update examples to reflect current best practices |
| 154 | +4. **Solicit Feedback**: Ask users which aspects need more examples |
| 155 | +5. **Compare with Usage**: Review real-world usage patterns and reflect them |
| 156 | + |
| 157 | +## How to Test Your Overview |
| 158 | + |
| 159 | +To ensure your API overview is effective: |
| 160 | + |
| 161 | +1. **Ask a New User**: Have someone unfamiliar with your package try using it with just the API documentation |
| 162 | +2. **Test Code Examples**: Verify all code examples run correctly |
| 163 | +3. **Check Patterns**: Ensure patterns shown are current best practices |
| 164 | +4. **Review for Completeness**: Confirm all essential functionality is represented |
| 165 | +5. **Check for AI Usability**: Verify AI assistants can successfully use the overview to generate correct code |
0 commit comments