docwright 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rspec +2 -0
- data/.rubocop.yml +8 -0
- data/CHANGELOG.md +25 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/LICENSE.txt +21 -0
- data/README.md +148 -0
- data/Rakefile +8 -0
- data/examples/.docwright.yml +11 -0
- data/examples/README.md +28 -0
- data/examples/api.md +20 -0
- data/examples/concerns.md +18 -0
- data/examples/database.md +27 -0
- data/examples/models.md +38 -0
- data/lib/docwright/checker.rb +151 -0
- data/lib/docwright/extractors/api_extractor.rb +24 -0
- data/lib/docwright/extractors/auth_extractor.rb +121 -0
- data/lib/docwright/extractors/background_jobs_extractor.rb +149 -0
- data/lib/docwright/extractors/concerns_extractor.rb +93 -0
- data/lib/docwright/extractors/database_extractor.rb +27 -0
- data/lib/docwright/extractors/model_extractor.rb +50 -0
- data/lib/docwright/extractors/services_extractor.rb +60 -0
- data/lib/docwright/generators/feature_generator.rb +74 -0
- data/lib/docwright/generators/manual_generator.rb +135 -0
- data/lib/docwright/merger.rb +59 -0
- data/lib/docwright/railtie.rb +10 -0
- data/lib/docwright/searcher.rb +55 -0
- data/lib/docwright/tasks/docwright.rake +28 -0
- data/lib/docwright/version.rb +5 -0
- data/lib/docwright/wizard.rb +243 -0
- data/lib/docwright.rb +23 -0
- data/sig/docwright.rbs +4 -0
- metadata +106 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: '089438eeadde6877f7ec2590b98c79d6698631099d3443223d77ca8f4cdbe581'
|
|
4
|
+
data.tar.gz: 2508d5a8a398a7c3df4650c2c32e9b09be1876a2bd23729b924c4914e6a34214
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 5a4b6893d2308dc9cb0ba1d487413a5f9df48653f8dcf32aca1039e921701bee53fddbf16d0f78d2b48e67335fbeb52f07548d119e87189dac333c3acc032b81
|
|
7
|
+
data.tar.gz: e316d0cfd343876518a2315d619177cbd9d05db76b121d756bb2099385f5879cb5594a1072695bf2f919c34722fc8b4b3ae73fc428acba1b5247a1d11fda1f0e
|
data/.rspec
ADDED
data/.rubocop.yml
ADDED
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to DocWright will be documented here.
|
|
4
|
+
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
|
|
5
|
+
|
|
6
|
+
## [Unreleased]
|
|
7
|
+
|
|
8
|
+
## [0.1.0] - Unreleased
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Railtie integration — DocWright hooks into Rails boot automatically
|
|
13
|
+
- `docwright:generate` — interactive wizard for guided documentation generation
|
|
14
|
+
- Database documentation — auto-extracts tables, columns, and types
|
|
15
|
+
- API documentation — auto-extracts routes and endpoints
|
|
16
|
+
- Model documentation — auto-extracts associations and validations
|
|
17
|
+
- Auth and permissions documentation — detects before/around/after action filters
|
|
18
|
+
- Background jobs documentation — detects job classes, queues, priorities, and schedules
|
|
19
|
+
- Services documentation — detects service classes and public methods
|
|
20
|
+
- Concerns documentation — detects model and controller concerns
|
|
21
|
+
- Manual templates — overview, setup, architecture, deployment, security, troubleshooting, business rules, changelog, readme
|
|
22
|
+
- Feature-specific docs — declared in `.docwright.yml`
|
|
23
|
+
- Smart merge markers — human-written content preserved across regenerations
|
|
24
|
+
- `docwright:check` — audit task for missing files, placeholder content, empty notes
|
|
25
|
+
- `docwright:search` — search across all documentation files
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
|
10
|
+
identity and orientation.
|
|
11
|
+
|
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
|
13
|
+
diverse, inclusive, and healthy community.
|
|
14
|
+
|
|
15
|
+
## Our Standards
|
|
16
|
+
|
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
|
18
|
+
community include:
|
|
19
|
+
|
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
|
24
|
+
and learning from the experience
|
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
|
26
|
+
community
|
|
27
|
+
|
|
28
|
+
Examples of unacceptable behavior include:
|
|
29
|
+
|
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
|
31
|
+
any kind
|
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
33
|
+
* Public or private harassment
|
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
|
35
|
+
without their explicit permission
|
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
|
37
|
+
professional setting
|
|
38
|
+
|
|
39
|
+
## Enforcement Responsibilities
|
|
40
|
+
|
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
|
44
|
+
or harmful.
|
|
45
|
+
|
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
|
49
|
+
decisions when appropriate.
|
|
50
|
+
|
|
51
|
+
## Scope
|
|
52
|
+
|
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
|
54
|
+
an individual is officially representing the community in public spaces.
|
|
55
|
+
Examples of representing our community include using an official email address,
|
|
56
|
+
posting via an official social media account, or acting as an appointed
|
|
57
|
+
representative at an online or offline event.
|
|
58
|
+
|
|
59
|
+
## Enforcement
|
|
60
|
+
|
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
|
62
|
+
reported to the community leaders responsible for enforcement at
|
|
63
|
+
[INSERT CONTACT METHOD].
|
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
65
|
+
|
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
|
67
|
+
reporter of any incident.
|
|
68
|
+
|
|
69
|
+
## Enforcement Guidelines
|
|
70
|
+
|
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
|
73
|
+
|
|
74
|
+
### 1. Correction
|
|
75
|
+
|
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
|
77
|
+
unprofessional or unwelcome in the community.
|
|
78
|
+
|
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
|
82
|
+
|
|
83
|
+
### 2. Warning
|
|
84
|
+
|
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
|
86
|
+
actions.
|
|
87
|
+
|
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
|
93
|
+
ban.
|
|
94
|
+
|
|
95
|
+
### 3. Temporary Ban
|
|
96
|
+
|
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
|
98
|
+
sustained inappropriate behavior.
|
|
99
|
+
|
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
|
101
|
+
communication with the community for a specified period of time. No public or
|
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
|
104
|
+
Violating these terms may lead to a permanent ban.
|
|
105
|
+
|
|
106
|
+
### 4. Permanent Ban
|
|
107
|
+
|
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
|
111
|
+
|
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
|
113
|
+
community.
|
|
114
|
+
|
|
115
|
+
## Attribution
|
|
116
|
+
|
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
|
118
|
+
version 2.1, available at
|
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
|
120
|
+
|
|
121
|
+
Community Impact Guidelines were inspired by
|
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
|
123
|
+
|
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
|
127
|
+
|
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Grace
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
# DocWright
|
|
2
|
+
|
|
3
|
+
Auto-generate and maintain documentation for your Rails application.
|
|
4
|
+
|
|
5
|
+
DocWright introspects your live Rails app to generate structured markdown
|
|
6
|
+
documentation for your database schema, API routes, models, services,
|
|
7
|
+
background jobs, and more. Human-written content is preserved across
|
|
8
|
+
regenerations using smart merge markers.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Add to your application's Gemfile:
|
|
13
|
+
|
|
14
|
+
```ruby
|
|
15
|
+
gem "docwright"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Then run:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
bundle install
|
|
22
|
+
bundle exec rake docwright:generate
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Generate documentation
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
rake docwright:generate
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Runs the interactive wizard which:
|
|
34
|
+
|
|
35
|
+
1. Scans your app and shows what will be generated
|
|
36
|
+
2. Asks y/n to continue
|
|
37
|
+
3. Generates auto files (database, API, models)
|
|
38
|
+
4. Walks you through each new manual file with write/editor/skip options
|
|
39
|
+
|
|
40
|
+
### Check documentation completeness
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
rake docwright:check
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Audits your docs and reports:
|
|
47
|
+
|
|
48
|
+
- Missing required files
|
|
49
|
+
- Files with placeholder content only
|
|
50
|
+
- Empty notes slots
|
|
51
|
+
|
|
52
|
+
### Search documentation
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
rake docwright:search[your_term]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
Searches across all generated markdown files.
|
|
59
|
+
|
|
60
|
+
## Generated files
|
|
61
|
+
|
|
62
|
+
### Auto-generated (always regenerated)
|
|
63
|
+
|
|
64
|
+
- `docs/database.md` — tables, columns, types
|
|
65
|
+
- `docs/api.md` — routes and endpoints
|
|
66
|
+
- `docs/models.md` — associations and validations per model
|
|
67
|
+
|
|
68
|
+
### Manual templates (written once, never overwritten)
|
|
69
|
+
|
|
70
|
+
- `docs/overview.md`
|
|
71
|
+
- `docs/setup.md`
|
|
72
|
+
- `docs/architecture.md`
|
|
73
|
+
- `docs/deployment.md`
|
|
74
|
+
- `docs/security.md`
|
|
75
|
+
- `docs/troubleshooting.md`
|
|
76
|
+
- `docs/business_rules.md`
|
|
77
|
+
- `docs/changelog.md`
|
|
78
|
+
- `docs/readme.md`
|
|
79
|
+
|
|
80
|
+
### Optional docs (declared in `.docwright.yml`)
|
|
81
|
+
|
|
82
|
+
- `docs/auth_and_permissions.md`
|
|
83
|
+
- `docs/background_jobs.md`
|
|
84
|
+
- `docs/services.md`
|
|
85
|
+
- `docs/concerns.md`
|
|
86
|
+
- `docs/features/*.md`
|
|
87
|
+
|
|
88
|
+
## Configuration
|
|
89
|
+
|
|
90
|
+
Create `.docwright.yml` in your Rails app root:
|
|
91
|
+
|
|
92
|
+
```yaml
|
|
93
|
+
# Optional narrative docs
|
|
94
|
+
optional_docs:
|
|
95
|
+
auth_and_permissions: true
|
|
96
|
+
background_jobs: true
|
|
97
|
+
services: true
|
|
98
|
+
concerns: true
|
|
99
|
+
|
|
100
|
+
# Feature-specific docs
|
|
101
|
+
features:
|
|
102
|
+
- name: qr_flow
|
|
103
|
+
description: QR code generation and scanning flow
|
|
104
|
+
- name: subscriptions
|
|
105
|
+
description: Billing and plan management
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## How merge markers work
|
|
109
|
+
|
|
110
|
+
Auto-generated content is wrapped in markers:
|
|
111
|
+
|
|
112
|
+
<!-- DOCWRIGHT:AUTO -->
|
|
113
|
+
|
|
114
|
+
auto content here — regenerated every time
|
|
115
|
+
|
|
116
|
+
<!-- DOCWRIGHT:END -->
|
|
117
|
+
|
|
118
|
+
Write your notes **outside** these markers — DocWright will never touch them.
|
|
119
|
+
|
|
120
|
+
For per-model files, named markers are used:
|
|
121
|
+
|
|
122
|
+
<!-- DOCWRIGHT:AUTO:Post -->
|
|
123
|
+
|
|
124
|
+
auto content for Post
|
|
125
|
+
|
|
126
|
+
<!-- DOCWRIGHT:END:Post -->
|
|
127
|
+
|
|
128
|
+
Notes for Post
|
|
129
|
+
|
|
130
|
+
your notes here — never overwritten
|
|
131
|
+
|
|
132
|
+
## Development
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
git clone https://github.com/GraceHtet/docwright.git
|
|
136
|
+
cd docwright
|
|
137
|
+
bundle install
|
|
138
|
+
bundle exec rspec
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Contributing
|
|
142
|
+
|
|
143
|
+
Bug reports and pull requests are welcome on
|
|
144
|
+
[GitHub](https://github.com/GraceHtet/docwright).
|
|
145
|
+
|
|
146
|
+
## License
|
|
147
|
+
|
|
148
|
+
MIT License. See [LICENSE.txt](LICENSE.txt).
|
data/Rakefile
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
features:
|
|
2
|
+
- name: qr_flow
|
|
3
|
+
description: QR code generation and scanning flow
|
|
4
|
+
- name: subscriptions
|
|
5
|
+
description: Billing, plan management, and renewals
|
|
6
|
+
|
|
7
|
+
optional_docs:
|
|
8
|
+
auth_and_permissions: true
|
|
9
|
+
background_jobs: true
|
|
10
|
+
services: true
|
|
11
|
+
concerns: true
|
data/examples/README.md
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# DocWright Examples
|
|
2
|
+
|
|
3
|
+
Sample output generated by DocWright from a Rails app with:
|
|
4
|
+
|
|
5
|
+
- 2 models (User, Post)
|
|
6
|
+
- Nested routes (users, posts)
|
|
7
|
+
- 1 concern (Publishable)
|
|
8
|
+
|
|
9
|
+
## Files
|
|
10
|
+
|
|
11
|
+
- `database.md` — auto-generated database schema documentation
|
|
12
|
+
- `api.md` — auto-generated API routes documentation
|
|
13
|
+
- `models.md` — auto-generated model documentation with merge markers
|
|
14
|
+
- `.docwright.yml` — sample configuration file
|
|
15
|
+
|
|
16
|
+
## Try it yourself
|
|
17
|
+
|
|
18
|
+
Add DocWright to your Rails app's Gemfile:
|
|
19
|
+
|
|
20
|
+
```ruby
|
|
21
|
+
gem "docwright"
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Then run:
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
rake docwright:generate
|
|
28
|
+
```
|
data/examples/api.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<!-- DOCWRIGHT:AUTO -->
|
|
2
|
+
# Api Documentation
|
|
3
|
+
|
|
4
|
+
- **GET** /users/:user_id/posts(.:format) -> posts#index
|
|
5
|
+
- **POST** /users/:user_id/posts(.:format) -> posts#create
|
|
6
|
+
- **GET** /users/:user_id/posts/new(.:format) -> posts#new
|
|
7
|
+
- **GET** /users/:user_id/posts/:id/edit(.:format) -> posts#edit
|
|
8
|
+
- **GET** /users/:user_id/posts/:id(.:format) -> posts#show
|
|
9
|
+
- **PATCH** /users/:user_id/posts/:id(.:format) -> posts#update
|
|
10
|
+
- **PUT** /users/:user_id/posts/:id(.:format) -> posts#update
|
|
11
|
+
- **DELETE** /users/:user_id/posts/:id(.:format) -> posts#destroy
|
|
12
|
+
- **GET** /users(.:format) -> users#index
|
|
13
|
+
- **POST** /users(.:format) -> users#create
|
|
14
|
+
- **GET** /users/new(.:format) -> users#new
|
|
15
|
+
- **GET** /users/:id/edit(.:format) -> users#edit
|
|
16
|
+
- **GET** /users/:id(.:format) -> users#show
|
|
17
|
+
- **PATCH** /users/:id(.:format) -> users#update
|
|
18
|
+
- **PUT** /users/:id(.:format) -> users#update
|
|
19
|
+
- **DELETE** /users/:id(.:format) -> users#destroy
|
|
20
|
+
<!-- DOCWRIGHT:END -->
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<!-- DOCWRIGHT:AUTO:Publishable -->
|
|
2
|
+
#### Publishable
|
|
3
|
+
- Type: Model Concern
|
|
4
|
+
- Location: app/models/concerns/publishable.rb
|
|
5
|
+
- Methods: publish, published?, unpublish
|
|
6
|
+
- Included in: Post
|
|
7
|
+
<!-- DOCWRIGHT:END:Publishable -->
|
|
8
|
+
#### Notes for Publishable
|
|
9
|
+
<!-- Describe what this concern adds and why it was extracted -->
|
|
10
|
+
|
|
11
|
+
<!-- DOCWRIGHT:AUTO:_summary -->
|
|
12
|
+
### Summary
|
|
13
|
+
- Total concerns: 1
|
|
14
|
+
- Model concerns: 1
|
|
15
|
+
- Controller concerns: 0
|
|
16
|
+
<!-- DOCWRIGHT:END:_summary -->
|
|
17
|
+
### Notes for _summary
|
|
18
|
+
<!-- Add your notes about _summary here -->
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<!-- DOCWRIGHT:AUTO -->
|
|
2
|
+
# Database Documentation
|
|
3
|
+
|
|
4
|
+
## posts
|
|
5
|
+
|
|
6
|
+
- **id** (integer)
|
|
7
|
+
- **title** (string)
|
|
8
|
+
- **body** (text)
|
|
9
|
+
- **user_id** (integer)
|
|
10
|
+
- **created_at** (datetime)
|
|
11
|
+
- **updated_at** (datetime)
|
|
12
|
+
- **published** (boolean)
|
|
13
|
+
|
|
14
|
+
## users
|
|
15
|
+
|
|
16
|
+
- **id** (integer)
|
|
17
|
+
- **name** (string)
|
|
18
|
+
- **email** (string)
|
|
19
|
+
- **created_at** (datetime)
|
|
20
|
+
- **updated_at** (datetime)
|
|
21
|
+
|
|
22
|
+
<!-- DOCWRIGHT:END -->
|
|
23
|
+
|
|
24
|
+
## My Notes
|
|
25
|
+
|
|
26
|
+
These are my personal notes that should survive regeneration.
|
|
27
|
+
created by Grace, and not auto replacable.
|
data/examples/models.md
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<!-- DOCWRIGHT:AUTO:Post -->
|
|
2
|
+
## Post
|
|
3
|
+
**Table:** posts
|
|
4
|
+
|
|
5
|
+
### Associations
|
|
6
|
+
- belongs_to :user
|
|
7
|
+
|
|
8
|
+
### Validations
|
|
9
|
+
- ActiveRecord::Validations::PresenceValidator on : user
|
|
10
|
+
- ActiveRecord::Validations::PresenceValidator on : title
|
|
11
|
+
- ActiveRecord::Validations::LengthValidator on : title
|
|
12
|
+
- ActiveRecord::Validations::PresenceValidator on : body
|
|
13
|
+
- ActiveRecord::Validations::LengthValidator on : body
|
|
14
|
+
<!-- DOCWRIGHT:END:Post -->
|
|
15
|
+
|
|
16
|
+
### Notes for Post
|
|
17
|
+
|
|
18
|
+
<!-- Add your notes about Post here -->
|
|
19
|
+
|
|
20
|
+
My note for post is here . They are blog post created by user
|
|
21
|
+
|
|
22
|
+
<!-- DOCWRIGHT:AUTO:User -->
|
|
23
|
+
## User
|
|
24
|
+
**Table:** users
|
|
25
|
+
|
|
26
|
+
### Associations
|
|
27
|
+
- has_many :posts
|
|
28
|
+
|
|
29
|
+
### Validations
|
|
30
|
+
- ActiveRecord::Validations::PresenceValidator on : name
|
|
31
|
+
- ActiveRecord::Validations::LengthValidator on : name
|
|
32
|
+
<!-- DOCWRIGHT:END:User -->
|
|
33
|
+
|
|
34
|
+
### Notes for User
|
|
35
|
+
|
|
36
|
+
<!-- Add your notes about User here -->
|
|
37
|
+
|
|
38
|
+
User is app user who can also create blog post.
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Docwright
|
|
4
|
+
class Checker
|
|
5
|
+
REQUIRED_FILES = %w[
|
|
6
|
+
docs/database.md
|
|
7
|
+
docs/api.md
|
|
8
|
+
docs/models.md
|
|
9
|
+
docs/overview.md
|
|
10
|
+
docs/business_rules.md
|
|
11
|
+
docs/setup.md
|
|
12
|
+
docs/architecture.md
|
|
13
|
+
docs/deployment.md
|
|
14
|
+
docs/security.md
|
|
15
|
+
docs/troubleshooting.md
|
|
16
|
+
docs/changelog.md
|
|
17
|
+
docs/readme.md
|
|
18
|
+
].freeze
|
|
19
|
+
|
|
20
|
+
def run
|
|
21
|
+
puts "\nDocWright Check"
|
|
22
|
+
puts "===============\n\n"
|
|
23
|
+
|
|
24
|
+
missing = check_required_files
|
|
25
|
+
missing += check_optional_files
|
|
26
|
+
placeholders = check_placeholder_content
|
|
27
|
+
empty_notes = check_note_slots
|
|
28
|
+
|
|
29
|
+
print_report(missing, placeholders, empty_notes)
|
|
30
|
+
|
|
31
|
+
exit(1) if missing.any? || placeholders.any? || empty_notes.any?
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
private
|
|
35
|
+
|
|
36
|
+
def check_required_files
|
|
37
|
+
missing = []
|
|
38
|
+
REQUIRED_FILES.each do |file|
|
|
39
|
+
if File.exist?(file)
|
|
40
|
+
puts "✅ #{file}"
|
|
41
|
+
else
|
|
42
|
+
puts "❌ #{file} — missing"
|
|
43
|
+
missing << file
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
missing
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def check_optional_files
|
|
51
|
+
missing = []
|
|
52
|
+
optional = load_optional_config
|
|
53
|
+
return missing if optional.empty?
|
|
54
|
+
|
|
55
|
+
optional_file_map = {
|
|
56
|
+
"auth_and_permissions" => "docs/auth_and_permissions.md",
|
|
57
|
+
"background_jobs" => "docs/background_jobs.md",
|
|
58
|
+
"services" => "docs/services.md",
|
|
59
|
+
"concerns" => "docs/concerns.md"
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
optional_file_map.each do |key, file|
|
|
63
|
+
next unless optional[key]
|
|
64
|
+
|
|
65
|
+
if File.exist?(file)
|
|
66
|
+
puts "✅ #{file}"
|
|
67
|
+
else
|
|
68
|
+
puts "❌ #{file} — missing (enabled in .docwright.yml)"
|
|
69
|
+
missing << file
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
missing
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def load_optional_config
|
|
77
|
+
return {} unless File.exist?(".docwright.yml")
|
|
78
|
+
|
|
79
|
+
require "yaml"
|
|
80
|
+
config = YAML.load_file(".docwright.yml")
|
|
81
|
+
return {} unless config.is_a?(Hash)
|
|
82
|
+
|
|
83
|
+
config["optional_docs"] || {}
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def check_placeholder_content
|
|
87
|
+
placeholders = []
|
|
88
|
+
all_files = REQUIRED_FILES.select { |f| File.exist?(f) }
|
|
89
|
+
|
|
90
|
+
all_files.each do |file|
|
|
91
|
+
content = File.read(file)
|
|
92
|
+
lines = content.lines.map(&:strip).reject(&:empty?)
|
|
93
|
+
real_lines = lines.reject { |l| l.start_with?("#", "<!--", "-->") }
|
|
94
|
+
|
|
95
|
+
if real_lines.empty?
|
|
96
|
+
puts "⚠ #{file} — placeholder content only"
|
|
97
|
+
placeholders << file
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
placeholders
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
def check_note_slots
|
|
105
|
+
empty_notes = []
|
|
106
|
+
md_files = Dir.glob("docs/**/*.md")
|
|
107
|
+
|
|
108
|
+
md_files.each do |file|
|
|
109
|
+
content = File.read(file)
|
|
110
|
+
lines = content.lines.map(&:chomp)
|
|
111
|
+
|
|
112
|
+
lines.each_with_index do |line, i|
|
|
113
|
+
next unless line.match?(/^#+\s+Notes for/)
|
|
114
|
+
|
|
115
|
+
following_lines = []
|
|
116
|
+
j = i + 1
|
|
117
|
+
while j < lines.size && !lines[j].match?(/^#+\s+Notes for/) && !lines[j].include?("DOCWRIGHT")
|
|
118
|
+
following_lines << lines[j]
|
|
119
|
+
j += 1
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
real_content = following_lines.map(&:strip).reject(&:empty?).reject { |l| l.start_with?("<!--", "-->") }
|
|
123
|
+
|
|
124
|
+
if real_content.empty?
|
|
125
|
+
puts "⚠ #{file} — empty notes slot: #{line.strip}"
|
|
126
|
+
empty_notes << "#{file}: #{line.strip}"
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
empty_notes
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
def print_report(missing, placeholders, empty_notes)
|
|
135
|
+
puts "\n==============="
|
|
136
|
+
puts "DocWright Check Summary"
|
|
137
|
+
puts "===============\n\n"
|
|
138
|
+
|
|
139
|
+
total_size = missing.size + placeholders.size + empty_notes.size
|
|
140
|
+
|
|
141
|
+
if total_size.zero?
|
|
142
|
+
puts "✅ All checks passed! Documentation looks complete."
|
|
143
|
+
else
|
|
144
|
+
puts "❌ Missing files: #{missing.size}"
|
|
145
|
+
puts "⚠ Placeholder content: #{placeholders.size}"
|
|
146
|
+
puts "⚠ Empty notes slots: #{empty_notes.size}"
|
|
147
|
+
puts "\nRun 'rake docwright:generate' to generate missing files."
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
end
|
|
151
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Docwright
|
|
4
|
+
module Extractors
|
|
5
|
+
class ApiExtractor
|
|
6
|
+
def generate
|
|
7
|
+
lines = ["# Api Documentation\n"]
|
|
8
|
+
|
|
9
|
+
routes = Rails.application.routes.routes
|
|
10
|
+
routes.each do |route|
|
|
11
|
+
next if route.name.to_s.start_with?("rails_")
|
|
12
|
+
next if route.verb.empty?
|
|
13
|
+
next if route.defaults[:controller].to_s.start_with?("rails/")
|
|
14
|
+
|
|
15
|
+
lines << "- **#{route.verb}** #{route.path.spec} -> #{route.defaults[:controller]}##{route.defaults[:action]}"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
FileUtils.mkdir_p("docs")
|
|
19
|
+
Docwright::Merger.write("docs/api.md", lines.join("\n"))
|
|
20
|
+
puts "DocWright: wrote docs/api.md"
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|