dmulholl / ark

A static website generator for people who enjoy the simpler things in life.
https://www.dmulholl.com/docs/ark/master/
The Unlicense
118 stars 7 forks source link

feat: using enumeration for event hooks instead of strings #10

Closed gvwilson closed 2 years ago

gvwilson commented 2 years ago

Newcomers to the project may find it hard to figure out the processing cycle because there's no central listing of possible event hooks. This PR addresses that:

  1. Add an Event enum to ivy/events.py listing known event hooks.
  2. Add an EVENT_NAMES dict to support string-to-enum translations for backward compatibility.
  3. Register all internal events using enum elements.
  4. Alter all internal event registrations and firings to use enums.

If this PR is useful, I'd be happy to add similar enumerations elsewhere, and to try to add documentation on the enum classes to try to explain the purpose/lifecycle of each element.

This PR also adds a .gitignore file to ignore build artifacts.

dmulholl commented 2 years ago

That's a very clever implementation. I like how you've maintained backwards compatibility with string hook names.

I'm going to take a proper look at the weekend when I have more time but I like it.

gvwilson commented 2 years ago

:+1: I'd be happy to hop on a call next week to try to debug the "empty node" problem I'm seeing (and to figure out if there's a way to implement a couple of my extensions that doesn't involve double-processing files).