pulp / pulp-docs

Python Package to help aggregating Pulp's multirepo ecosystem into a unified doc.
https://pedro-psb.github.io/pulp-docs/
2 stars 3 forks source link

Add more stable mechanism for ordering files/folders #20

Closed pedro-psb closed 1 month ago

pedro-psb commented 4 months ago

Problem

The current way of ordering files and folders is by prefixing numbers to it.

While this solution has the advantage of being very simple, it has some drawbacks (TLDR: high coupling between filenames, display names and ordering):

Alternatives

All of these solutions could be homegrown or plugin-based. It requires some research.

1) Use metadata-defined permalink

I'm not sure if it is possible, but if we can define the link using a "permalink" metadata field (for files and directories) we wouldn't have the unstable-link issue anymore and could continue ordering by rename.

This seems the simplest solution, as it won't require an implementation-level ordering mechanism (of parsing ordering metadata and sorting files)

2) Implicit metadata ordering

Use metadata to handle display names and ordering.

3) Explicit metadata ordering

An alternative for ordering is creating an explicit index in the meta.yml, listing the order of the filenames. This can be flexible so it doesn't mean to just include those, but to prioritize this ordering and then sort the rest lexigraphically.

$ ls
meta.yml
spam.md
eggs.md
foo.md
bar.md

$ cat meta.yml
title: Name of the dir
ordering:
- foo.md
- bar.md

Final ordering:

- foo.md
- bar.md
- eggs.md # not excluded because ommited from meta.yml
- spam.md # sorted lexicographically
pedro-psb commented 4 months ago

Found some plugins that may help with this: