defenseunicorns / defenseunicorns/pepr-docs

Restructure `pepr-excellent-examples` Repository to Avoid Data Transformation

Open
#188 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
6
Forks
1
Avg merge
23h 7m
Merged PRs (30d)
14

Description

## Description

The current structure of the `pepr-excellent-examples` repository requires significant data transformation and categorization during the build process. All example directories follow the `hello-pepr-*` naming pattern, which necessitates:

1. **Slug generation** - Stripping the `hello-pepr-` prefix to create clean URLs
2. **Category extraction** - Parsing README headings to determine if examples should be nested in category folders
3. **Title processing** - Extracting and cleaning titles from markdown content
4. **Directory restructuring** - Moving files into category subdirectories based on parsed metadata

**Current workflow (from `scripts/index.mjs` and `scripts/lib/examples-processing.mjs`):**
- Read each `hello-pepr-*` directory
- Parse README.md to extract category from heading (e.g., "Action: Mutate" → category "action")
- Generate slug by removing `hello-pepr-` prefix
- Create category directories dynamically
- Copy content with transformed frontmatter

**Problems with current approach:**
- **Complex build logic** - Significant code dedicated to parsing and transforming example metadata
- **Fragile parsing** - Relies on specific heading formats (e.g., "Category: Title" with colon separator)
- **Harder to debug** - Issues with categorization require understanding the transformation pipeline
- **Maintenance burden** - Changes to categorization require updating build scripts

**Proposed solution:**
Restructure the `pepr-excellent-examples` repository to match the desired output structure:
```
pepr-excellent-examples/
├── actions/
│ ├── mutate/
│ ├── validate/
│ └── watch/
├── capabilities/
│ ├── ...
└── module/
└── README.md
```

This would eliminate the need for:
- `extractExampleCategory()` function
- `generateExampleSlug()` function
- `removeHeading()` function
- Category-based directory creation logic
- Complex slug generation with version handling

## Related Files

- https://github.com/defenseunicorns/pepr-docs/blob/main/scripts/index.mjs (lines 419-485)
- https://github.com/defenseunicorns/pepr-docs/blob/main/scripts/lib/examples-processing.mjs
- https://github.com/defenseunicorns/pepr-excellent-examples (external repository)

## Definition of Done

- [ ] **Update pepr-excellent-examples** - Restructure repository with new directory layout
- [ ] **Simplify build scripts** - Remove transformation logic from `scripts/index.mjs` and `scripts/lib/examples-processing.mjs`
- [ ] **Test build process** - Verify examples are correctly processed with simplified logic
- [ ] **Update documentation** - Document new structure in pepr-excellent-examples README

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.