You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* - **Password Security**: Bcrypt hashing with salt
100
-
*
114
+
*
101
115
* ## Usage Example
102
-
*
116
+
*
103
117
* ```php
104
118
* $auth = new AuthService();
105
119
* $result = $auth->authenticate($credentials);
106
120
* ```
107
-
*
121
+
*
108
122
* @nav Authentication / User Service
109
123
* @uses \App\Models\User
110
124
* @uses \App\Services\EmailService
@@ -114,29 +128,296 @@ class AuthService
114
128
{
115
129
/**
116
130
* Authenticate user credentials
117
-
*
131
+
*
118
132
* @functional
119
133
* This method validates user credentials against the database and
120
134
* creates a secure session if authentication is successful.
121
-
*
135
+
*
136
+
* This process appears as a child page under the main User Service
137
+
* in the navigation, demonstrating hierarchical organization.
138
+
*
122
139
* @nav Authentication / Login Process
123
140
* @uses \App\Models\User
124
141
*/
125
142
public function authenticate(array $credentials): bool
126
143
{
127
144
// Implementation...
128
145
}
146
+
147
+
/**
148
+
* Multi-factor authentication verification
149
+
*
150
+
* @functional
151
+
* Handles the second factor of authentication using TOTP tokens,
152
+
* SMS codes, or backup codes for enhanced security.
153
+
*
154
+
* This also appears under the User Service section, showing how
155
+
* multiple related methods are grouped together.
156
+
*
157
+
* @nav Authentication / MFA Verification
158
+
* @uses \App\Models\User
159
+
* @uses \App\Services\TotpService
160
+
*/
161
+
public function verifyMfaToken(string $token): bool
162
+
{
163
+
// Implementation...
164
+
}
129
165
}
130
-
```
166
+
````
131
167
132
168
### Available Annotations
133
169
134
-
-**`@functional`**: Marks the documentation block for extraction (required)
170
+
The following annotations work in **both** PHPDoc comments and static markdown files:
171
+
172
+
##### Navigation Annotations
135
173
-**`@nav`**: Sets the navigation path (e.g., "Authentication / User Service")
174
+
-**`@navid`**: Sets a unique identifier for referencing this page as a parent
175
+
-**`@navparent`**: References a parent page by its `@navid` for explicit hierarchical navigation
176
+
177
+
##### Content Annotations
136
178
-**`@uses`**: Links to dependencies that will be cross-referenced
137
179
-**`@link`**: Adds external links to the documentation
138
180
-**`@links`**: Alternative syntax for links
139
181
182
+
##### PHPDoc-Specific Annotations
183
+
-**`@functional`**: Marks the documentation block for extraction (required)
184
+
185
+
> **Note**: Hierarchical navigation works in two ways:
186
+
> -**Automatic grouping**: Pages with shared path prefixes in `@nav` paths (like "Authentication / User Service" and "Authentication / Login Process") are automatically grouped under "Authentication"
187
+
> -**Explicit parent-child**: Use `@navid` and `@navparent` for explicit parent-child relationships across any content type
188
+
189
+
### Working with Static Content Files
190
+
191
+
In addition to PHPDoc comments, you can include existing markdown files in your documentation. This is useful for specifications, guides, tutorials, or any content that exists outside your code.
192
+
193
+
#### Setting up Static Content
194
+
195
+
1.**Configure paths** in your `config/docs.php`:
196
+
197
+
```php
198
+
'static_content' => [
199
+
'specifications' => [
200
+
'path' => base_path('docs/specifications'),
201
+
'nav_prefix' => 'Specifications',
202
+
],
203
+
'guides' => [
204
+
'path' => base_path('docs/guides'),
205
+
'nav_prefix' => 'User Guides',
206
+
],
207
+
],
208
+
```
209
+
210
+
2.**Create your markdown files** with cross-references:
This page describes individual endpoints and inherits from the API Overview page.
252
+
253
+
See also: [Database Schema](../specifications/database.md) for data structure details.
254
+
```
255
+
256
+
#### Features of Static Content
257
+
258
+
-**Automatic processing**: Files are automatically discovered and processed
259
+
-**Flexible navigation**: Use `@nav` to customize navigation paths
260
+
-**Hierarchical structure**: Use `@navid` and `@navparent` for parent-child relationships
261
+
-**Cross-references**: Use standard markdown links to reference other files
262
+
-**YAML frontmatter support**: Standard markdown frontmatter is automatically stripped
263
+
-**Title extraction**: Page titles are extracted from the first `# heading` in the file
264
+
-**Directory structure**: File organization is preserved in the navigation structure
265
+
266
+
### Cross-Reference Linking
267
+
268
+
The package includes a powerful cross-reference linking system that allows you to create links between documentation pages using special syntax. The system automatically generates link text, validates references, and creates bi-directional links.
269
+
270
+
#### Basic Syntax
271
+
272
+
There are two ways to create cross-references:
273
+
274
+
**1. Reference by Class/Owner (`@ref`)**
275
+
276
+
Use `@ref:` to reference a page by its fully qualified class name or owner identifier:
277
+
278
+
```markdown
279
+
For authentication, see [@ref:App\Services\AuthService].
280
+
```
281
+
282
+
This automatically generates a link with smart title extraction from the target page.
283
+
284
+
**2. Reference by Navigation ID (`@navid`)**
285
+
286
+
Use `@navid:` to reference a page by its custom navigation identifier:
287
+
288
+
```markdown
289
+
More details in the [@navid:api] documentation.
290
+
```
291
+
292
+
#### Auto-Generated Titles
293
+
294
+
The cross-reference system automatically generates meaningful link text using a smart fallback chain:
295
+
296
+
1.**H1 Title**: First, it extracts the first H1 heading from the target page's content
297
+
2.**Navigation Path**: If no H1 is found, it uses the last segment of the `@nav` path
298
+
3.**Class Name**: Finally, it falls back to the class name from the owner identifier
299
+
300
+
**Example:**
301
+
302
+
```php
303
+
/**
304
+
* User authentication service
305
+
*
306
+
* @functional
307
+
* This service handles authentication.
308
+
*
309
+
* # Complete Authentication System
310
+
* ...
311
+
*
312
+
* @nav Services / Auth
313
+
*/
314
+
class AuthService {}
315
+
```
316
+
317
+
When referenced with `[@ref:App\Services\AuthService]`, the generated link text will be:
You can override the auto-generated title by providing custom link text:
325
+
326
+
```markdown
327
+
See the [authentication setup guide](@ref:App\Services\AuthService).
328
+
Read more about [our API](@navid:api).
329
+
```
330
+
331
+
#### Bi-Directional Discovery
332
+
333
+
The system automatically tracks all cross-references and generates "Referenced by" sections on target pages. This creates bidirectional linking without any manual maintenance.
334
+
335
+
**Example:**
336
+
337
+
If you reference `App\Services\AuthService` from multiple pages:
338
+
339
+
```markdown
340
+
<!-- In guards.md -->
341
+
The guard system uses [@ref:App\Services\AuthService].
342
+
343
+
<!-- In middleware.md -->
344
+
Middleware delegates to [@ref:App\Services\AuthService].
345
+
```
346
+
347
+
The `AuthService` documentation page will automatically include:
348
+
349
+
```markdown
350
+
## Referenced by
351
+
352
+
This page is referenced by the following pages:
353
+
354
+
* [Guards / Authentication Guards](./guards/)
355
+
* [Middleware / Auth Middleware](./middleware/)
356
+
```
357
+
358
+
#### Error Handling and Validation
359
+
360
+
The build process validates all cross-references and **fails with informative errors** if broken references are found:
361
+
362
+
```
363
+
RuntimeException: Broken reference: @ref:App\NonExistent\Class in App\Services\AuthService
364
+
```
365
+
366
+
This ensures your documentation links stay accurate as your codebase evolves.
367
+
368
+
#### Cross-Referencing Between PHPDoc and Static Content
369
+
370
+
Cross-references work seamlessly across both PHPDoc comments and static markdown files:
371
+
372
+
**PHPDoc referencing static content:**
373
+
```php
374
+
/**
375
+
* @functional
376
+
* Implementation details in [@navid:api-spec].
377
+
*/
378
+
class ApiController {}
379
+
```
380
+
381
+
**Static content referencing PHPDoc:**
382
+
```markdown
383
+
<!-- docs/guides/api-guide.md -->
384
+
@navid api-spec
385
+
386
+
# API Specification
387
+
388
+
The implementation is in [@ref:App\Controllers\ApiController].
389
+
```
390
+
391
+
#### Best Practices
392
+
393
+
**When to use `@ref` vs `@navid`:**
394
+
395
+
-**Use `@ref`** for referencing specific classes, methods, or PHPDoc-documented code
396
+
-**Use `@navid`** for referencing conceptual pages, guides, or when you want a stable reference that won't change with refactoring
397
+
398
+
**Setting up navigation IDs:**
399
+
400
+
```php
401
+
/**
402
+
* @functional
403
+
* Main authentication service documentation
404
+
*
405
+
* @navid auth-service // Stable identifier for references
406
+
* @nav Services / Authentication
407
+
*/
408
+
class AuthService {}
409
+
```
410
+
411
+
```markdown
412
+
<!-- docs/guides/authentication.md -->
413
+
@navid auth-guide
414
+
@nav Guides / Authentication Setup
415
+
416
+
# Authentication Guide
417
+
418
+
This guide complements the [@navid:auth-service] implementation.
419
+
```
420
+
140
421
### Generate Documentation
141
422
142
423
Generate your documentation using the Artisan command:
@@ -288,7 +569,7 @@ If you discover any security related issues, please email [email protected]
0 commit comments