Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customisable catalogue sort #36

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

byjpr
Copy link

@byjpr byjpr commented Apr 22, 2022

Open the sorting functions to allow devs to choose how their navigation is structured.

@byjpr
Copy link
Author

byjpr commented Apr 22, 2022

Currently I have created:

  1. 2 custom structs, Category, and Module.
  2. Item component, and tree component
  3. Transpiler that takes the current components from Util.get_components_info/0 and turns it into the custom structs

To-do: Figure out how to allow hooking and transformation.

@byjpr byjpr marked this pull request as ready for review April 23, 2022 17:50
@byjpr
Copy link
Author

byjpr commented Apr 23, 2022

We now have a fully working extendable sorting system for modules. I've included two examples of sorting functions that are enabled by default.

  • CategoryFirst will sort catalogues/categories to the top of each list
  • ByCatalogueABC will sort each catalogue (not categories) in alphabetical order

The two examples also show how you can sort at different levels, by either doing a deep sort (the entire AST) or you could do a shallow sort where you only do top-level (or really any level you would like).

What was my motivation?
I'm currently working on Shopify Polaris for Elixir (for my own personal fun), and wanted to be able to order the docs in the same way that is shown on the Polaris docs without needing to use Module Names for sorting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant