Skip to content

Commit eb91454

Browse files
Bissbertclaude
andcommitted
Add MkDocs documentation site
- Add mkdocs.yml with Material theme configuration - Add docs/ with index, API reference, CLI usage, and examples - Add GitHub Actions workflow for docs deployment Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent f436eb3 commit eb91454

6 files changed

Lines changed: 866 additions & 0 deletions

File tree

.github/workflows/docs.yml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Reusable workflow: Deploy documentation to GitHub Pages
2+
# Usage: Copy to each package repo's .github/workflows/
3+
4+
name: Deploy Documentation
5+
6+
on:
7+
push:
8+
branches: [main]
9+
paths:
10+
- 'docs/**'
11+
- 'src/**'
12+
- 'mkdocs.yml'
13+
workflow_dispatch:
14+
15+
permissions:
16+
contents: read
17+
pages: write
18+
id-token: write
19+
20+
concurrency:
21+
group: pages
22+
cancel-in-progress: true
23+
24+
jobs:
25+
build:
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: actions/checkout@v4
29+
30+
- name: Set up Python
31+
uses: actions/setup-python@v5
32+
with:
33+
python-version: '3.11'
34+
35+
- name: Install dependencies
36+
run: |
37+
pip install mkdocs mkdocs-material mkdocstrings[python]
38+
39+
- name: Build documentation
40+
run: mkdocs build
41+
42+
- name: Upload artifact
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: site/
46+
47+
deploy:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
environment:
51+
name: github-pages
52+
url: ${{ steps.deployment.outputs.page_url }}
53+
steps:
54+
- name: Deploy to GitHub Pages
55+
id: deployment
56+
uses: actions/deploy-pages@v4

docs/api.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
# API Reference
2+
3+
## Core Functions
4+
5+
### parse_cdl
6+
7+
Parse a CDL string into a structured description.
8+
9+
```python
10+
from cdl_parser import parse_cdl
11+
12+
desc = parse_cdl("cubic[m3m]:{111}@1.0 + {100}@1.3")
13+
```
14+
15+
::: cdl_parser.parse_cdl
16+
17+
### validate_cdl
18+
19+
Validate a CDL string without parsing.
20+
21+
```python
22+
from cdl_parser import validate_cdl
23+
24+
is_valid, error = validate_cdl("cubic[m3m]:{111}")
25+
if not is_valid:
26+
print(f"Error: {error}")
27+
```
28+
29+
::: cdl_parser.validate_cdl
30+
31+
## Data Classes
32+
33+
### CrystalDescription
34+
35+
Main output of CDL parsing.
36+
37+
```python
38+
@dataclass
39+
class CrystalDescription:
40+
system: str # Crystal system
41+
point_group: str # Point group symbol
42+
forms: List[CrystalForm] # Crystal forms
43+
modifications: List[Modification] # Morphological mods
44+
twin: Optional[TwinSpec] # Twin specification
45+
```
46+
47+
::: cdl_parser.CrystalDescription
48+
49+
### MillerIndex
50+
51+
Miller index representation.
52+
53+
```python
54+
@dataclass
55+
class MillerIndex:
56+
h: int
57+
k: int
58+
l: int
59+
i: Optional[int] = None # For 4-index notation
60+
61+
def as_tuple(self) -> tuple[int, ...]
62+
def as_3index(self) -> tuple[int, int, int]
63+
```
64+
65+
::: cdl_parser.MillerIndex
66+
67+
### CrystalForm
68+
69+
A crystal form with scale.
70+
71+
```python
72+
@dataclass
73+
class CrystalForm:
74+
miller: MillerIndex
75+
scale: float = 1.0
76+
name: Optional[str] = None
77+
```
78+
79+
::: cdl_parser.CrystalForm
80+
81+
## Constants
82+
83+
```python
84+
from cdl_parser import (
85+
CRYSTAL_SYSTEMS, # Set of system names
86+
POINT_GROUPS, # Dict[system, Set[groups]]
87+
DEFAULT_POINT_GROUPS, # Dict[system, default_group]
88+
NAMED_FORMS, # Dict[name, (h, k, l)]
89+
TWIN_LAWS, # Set of twin law names
90+
)
91+
```
92+
93+
### CRYSTAL_SYSTEMS
94+
95+
Set of valid crystal system names:
96+
97+
- `cubic`
98+
- `tetragonal`
99+
- `orthorhombic`
100+
- `hexagonal`
101+
- `trigonal`
102+
- `monoclinic`
103+
- `triclinic`
104+
105+
### POINT_GROUPS
106+
107+
Dictionary mapping each crystal system to its valid point groups.
108+
109+
### DEFAULT_POINT_GROUPS
110+
111+
Dictionary mapping each crystal system to its default (highest symmetry) point group.
112+
113+
### NAMED_FORMS
114+
115+
Dictionary mapping common form names to their Miller indices:
116+
117+
| Name | Miller Index |
118+
|------|-------------|
119+
| `octahedron` | {111} |
120+
| `cube` | {100} |
121+
| `dodecahedron` | {110} |
122+
| `trapezohedron` | {211} |
123+
| `prism` | {10-10} |
124+
| `basal` | {0001} |
125+
| `rhombohedron` | {10-11} |
126+
127+
### TWIN_LAWS
128+
129+
Set of recognized twin law names:
130+
131+
- `spinel` - Spinel law (111) twin
132+
- `brazil` - Brazil law quartz twin
133+
- `japan` - Japan law quartz twin
134+
- `fluorite` - Fluorite interpenetration twin
135+
- `iron_cross` - Iron cross pyrite twin
136+
137+
## Exceptions
138+
139+
### ParseError
140+
141+
Raised when parsing fails due to syntax errors.
142+
143+
```python
144+
from cdl_parser import ParseError
145+
146+
try:
147+
desc = parse_cdl("invalid{{{")
148+
except ParseError as e:
149+
print(f"Syntax error at position {e.position}: {e.message}")
150+
```
151+
152+
::: cdl_parser.ParseError
153+
154+
### ValidationError
155+
156+
Raised when validation fails due to invalid values.
157+
158+
```python
159+
from cdl_parser import ValidationError
160+
161+
try:
162+
desc = parse_cdl("invalid[xxx]:{111}")
163+
except ValidationError as e:
164+
print(f"Validation error: {e.message}")
165+
```
166+
167+
::: cdl_parser.ValidationError

0 commit comments

Comments
 (0)