Skip to content

Commit 57ecb32

Browse files
committed
first commit of docs
1 parent e519e28 commit 57ecb32

File tree

10 files changed

+1913
-0
lines changed

10 files changed

+1913
-0
lines changed

.github/workflows/docs.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Deploy Documentation
2+
3+
on:
4+
# Trigger on push to main branch
5+
push:
6+
branches: [main, master]
7+
paths:
8+
- 'docs/**'
9+
- 'mkdocs.yml'
10+
- 'pytorch_segmentation_models_trainer/**/*.py' # Rebuild on code changes for API docs
11+
- '.github/workflows/docs.yml'
12+
13+
# Allow manual triggering
14+
workflow_dispatch:
15+
16+
# Trigger on pull requests for testing (but don't deploy)
17+
pull_request:
18+
branches: [main, master]
19+
paths:
20+
- 'docs/**'
21+
- 'mkdocs.yml'
22+
23+
# Set permissions for GitHub Pages deployment
24+
permissions:
25+
contents: read
26+
pages: write
27+
id-token: write
28+
29+
# Allow only one concurrent deployment
30+
concurrency:
31+
group: "pages"
32+
cancel-in-progress: false
33+
34+
jobs:
35+
# Build documentation
36+
build:
37+
runs-on: ubuntu-latest
38+
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0 # Fetch full history for git info
43+
44+
- name: Set up Python
45+
uses: actions/setup-python@v4
46+
with:
47+
python-version: '3.9'
48+
cache: 'pip'
49+
50+
- name: Install dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
pip install mkdocs mkdocs-material mkdocstrings[python] mkdocs-jupyter
54+
# Install your package for API documentation
55+
pip install -e .
56+
57+
- name: Configure Git for mkdocs
58+
run: |
59+
git config --global user.name "github-actions[bot]"
60+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
61+
62+
- name: Build documentation
63+
run: mkdocs build --strict
64+
65+
- name: Upload documentation artifacts
66+
uses: actions/upload-pages-artifact@v2
67+
with:
68+
path: ./site
69+
70+
# Deploy to GitHub Pages (only on main branch)
71+
deploy:
72+
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
73+
environment:
74+
name: github-pages
75+
url: ${{ steps.deployment.outputs.page_url }}
76+
runs-on: ubuntu-latest
77+
needs: build
78+
steps:
79+
- name: Deploy to GitHub Pages
80+
id: deployment
81+
uses: actions/deploy-pages@v2
82+
83+
# Test documentation build on PRs (without deploying)
84+
test:
85+
if: github.event_name == 'pull_request'
86+
runs-on: ubuntu-latest
87+
steps:
88+
- name: Checkout repository
89+
uses: actions/checkout@v4
90+
91+
- name: Set up Python
92+
uses: actions/setup-python@v4
93+
with:
94+
python-version: '3.9'
95+
cache: 'pip'
96+
97+
- name: Install dependencies
98+
run: |
99+
python -m pip install --upgrade pip
100+
pip install mkdocs mkdocs-material mkdocstrings[python] mkdocs-jupyter
101+
pip install -e .
102+
103+
- name: Test documentation build
104+
run: mkdocs build --strict
105+
106+
- name: Test internal links
107+
run: |
108+
# Install link checker
109+
pip install mkdocs-linkcheck
110+
# Check for broken internal links
111+
mkdocs build --strict --site-dir test_site
112+
113+
- name: Comment PR with preview info
114+
if: github.event_name == 'pull_request'
115+
uses: actions/github-script@v6
116+
with:
117+
script: |
118+
github.rest.issues.createComment({
119+
issue_number: context.issue.number,
120+
owner: context.repo.owner,
121+
repo: context.repo.repo,
122+
body: '📚 Documentation build successful! The changes look good and ready to be deployed.'
123+
})

docs/README.md

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
1+
# Documentation
2+
3+
This folder contains the documentation for PyTorch Segmentation Models Trainer.
4+
5+
## Building Documentation
6+
7+
### Prerequisites
8+
9+
```bash
10+
pip install mkdocs mkdocs-material mkdocstrings[python] mkdocs-jupyter
11+
```
12+
13+
### Local Development
14+
15+
```bash
16+
# Serve documentation locally with auto-reload
17+
mkdocs serve
18+
19+
# Open http://127.0.0.1:8000 in your browser
20+
```
21+
22+
### Building Static Site
23+
24+
```bash
25+
# Build static HTML files
26+
mkdocs build
27+
28+
# Output will be in site/ directory
29+
```
30+
31+
## Deployment
32+
33+
### GitHub Pages
34+
35+
```bash
36+
# Deploy to GitHub Pages (requires push access)
37+
mkdocs gh-deploy
38+
```
39+
40+
### Manual Deployment
41+
42+
1. Build the documentation:
43+
```bash
44+
mkdocs build
45+
```
46+
47+
2. Copy the `site/` folder contents to your web server.
48+
49+
## Writing Documentation
50+
51+
### File Structure
52+
53+
- `docs/` - All documentation files
54+
- `mkdocs.yml` - Configuration file
55+
- Use `.md` files for content
56+
- Follow the navigation structure in `mkdocs.yml`
57+
58+
### Writing Guidelines
59+
60+
1. **Use descriptive headings** with proper hierarchy
61+
2. **Include code examples** with syntax highlighting
62+
3. **Add tips and warnings** using admonitions:
63+
```markdown
64+
!!! tip "Pro Tip"
65+
This is a helpful tip
66+
67+
!!! warning "Important"
68+
This is a warning
69+
```
70+
71+
4. **Cross-reference** other pages:
72+
```markdown
73+
See the [Installation Guide](getting-started/installation.md)
74+
```
75+
76+
5. **API Documentation** using mkdocstrings:
77+
```markdown
78+
::: pytorch_segmentation_models_trainer.main
79+
options:
80+
show_source: true
81+
```
82+
83+
### Adding New Pages
84+
85+
1. Create the markdown file in appropriate directory
86+
2. Add to navigation in `mkdocs.yml`:
87+
```yaml
88+
nav:
89+
- New Section:
90+
- New Page: path/to/new-page.md
91+
```
92+
93+
## Auto-generated Content
94+
95+
Some content is automatically generated:
96+
97+
- **API Reference**: From docstrings using mkdocstrings
98+
- **Navigation**: From `mkdocs.yml` structure
99+
- **Search Index**: Automatically built by MkDocs
100+
101+
## Customization
102+
103+
### Theme Customization
104+
105+
Edit `mkdocs.yml`:
106+
107+
```yaml
108+
theme:
109+
name: material
110+
palette:
111+
primary: blue
112+
accent: blue
113+
features:
114+
- navigation.tabs
115+
- search.highlight
116+
```
117+
118+
### Adding Extensions
119+
120+
Add to `mkdocs.yml`:
121+
122+
```yaml
123+
markdown_extensions:
124+
- pymdownx.superfences
125+
- admonition
126+
- tables
127+
```
128+
129+
## Contributing
130+
131+
1. Write clear, concise documentation
132+
2. Include working examples
133+
3. Test all code snippets
134+
4. Check links work correctly
135+
5. Preview locally before submitting
136+
137+
## Troubleshooting
138+
139+
### Common Issues
140+
141+
**Missing dependencies**:
142+
```bash
143+
pip install mkdocs-material mkdocstrings[python]
144+
```
145+
146+
**API docs not generating**:
147+
- Check docstrings exist in Python files
148+
- Verify module paths in `::: module.name` references
149+
150+
**Build errors**:
151+
- Check YAML syntax in `mkdocs.yml`
152+
- Verify all referenced files exist
153+
- Check markdown syntax
154+
155+
**Broken links**:
156+
- Use relative paths: `[link](../other-page.md)`
157+
- Check file extensions match exactly

0 commit comments

Comments
 (0)