---
name: step-08-documentation
description: Generate in-app user documentation for the module
prev_step: steps/step-07-tests.md
next_step: null
---

# Step 8: Documentation Generation

## CONDITION D'EXECUTION

Ce step s'execute si :
- Le feature.json du module contient `documentation.userDocRequired: true`
- OU si aucun feature.json n'existe (generation par defaut - documentation est toujours utile)

Si `documentation.userDocRequired` est explicitement `false`, afficher :

```
ℹ Documentation skipped (userDocRequired: false in feature.json)
```

Et passer directement au recapitulatif final.

## MANDATORY EXECUTION RULES

- ALWAYS check feature.json for documentation requirements before generating
- ALWAYS invoke the `/documentation` skill (not manual generation)
- ALWAYS update feature.json documentation status after generation
- YOU ARE AN ORCHESTRATOR calling `/documentation`, not a generator

## YOUR TASK

Declencher le skill `/documentation` pour generer la page de documentation in-app du module.
Le skill `/documentation` lit les sources du module (entites, controleur, permissions, feature.json)
et genere une page de documentation data-driven integree dans l'application web.

## EXECUTION

### 1. Verify Prerequisites

Before invoking documentation generation, verify:

- [ ] Module backend is generated (controller, services, entities exist)
- [ ] Module frontend is generated (pages, components exist)
- [ ] i18n translations exist (4 languages: fr, en, it, de)
- [ ] Permissions are defined (Permissions.cs exists)

If any prerequisite is missing, warn but continue (documentation can reference planned features).

### 2. Check feature.json Documentation Requirements

```
Read feature.json for the current module:
  - documentation.userDocRequired → generate user documentation page
  - documentation.techDocRequired → generate technical documentation (ERD)
```

### 3. Invoke /documentation Skill

**For user documentation (default):**

Equivalent of: `/documentation user {module_name}`

The `/documentation` skill will:
1. Read sources (entities, controller, permissions, feature.json specification)
2. Generate `doc-data.ts` (structured data file, ~50 lines)
3. Generate `index.tsx` (page wrapper, ~10 lines)
4. Generate i18n FR file (source language - EN/IT/DE deferred to translation pipeline)
5. Update `docs-manifest.json`
6. Update `App.tsx` routing
7. Update `UserIndexPage.tsx` (add module entry)

**For technical documentation (if techDocRequired):**

Equivalent of: `/documentation database {module_name}`

Generates database ERD and schema documentation page.

### 4. Update feature.json Status

If feature.json exists, update the documentation status:

```
ba-writer.enrichSection({
  featureId: {feature_id},
  section: "documentation",
  data: {
    status: "generated",
    generatedAt: "{ISO timestamp}"
  }
})
```

### 5. Present Result

```
═══════════════════════════════════════════════════════════════
  ✓ DOCUMENTATION GENERATED - {module_name}
═══════════════════════════════════════════════════════════════

Files generated:
  ✓ docs/business/{app}/{module}/doc-data.ts
  ✓ docs/business/{app}/{module}/index.tsx
  ✓ i18n/locales/fr/docs-{app}-{module}.json
  ✓ docs-manifest.json (updated)
  ✓ App.tsx (route added)
  ✓ UserIndexPage.tsx (module entry added)

Documentation URL: /system/docs/user/{app}/{module}
═══════════════════════════════════════════════════════════════
```

## FINAL RECAP

After documentation generation (or skip), present the complete module recap:

```
═══════════════════════════════════════════════════════════════
  ✓ MODULE COMPLETE - {module_name}
═══════════════════════════════════════════════════════════════

  Step 01: Navigation     ✓
  Step 02: Permissions    ✓
  Step 03: Roles          ✓
  Step 04: Backend        ✓
  Step 05: Frontend       ✓
  Step 06: Migration      ✓
  Step 07: Tests          ✓
  Step 08: Documentation  ✓ (or ⊘ skipped)

  Total files generated: {count}
═══════════════════════════════════════════════════════════════
```

## NEXT STEP

End of `/application` workflow. No further steps.
