logo

drewdevault.com

[mirror] blog and personal website of Drew DeVault git clone https://hacktivis.me/git/mirror/drewdevault.com.git

Add-a-contrib-directory.md (3685B)


  1. ---
  2. date: 2020-06-06
  3. title: Add a "contrib" directory to your projects
  4. layout: post
  5. tags: [software, practices]
  6. ---
  7. There's a common pattern among free- and open-source software projects to
  8. include a "contrib" directory at the top of their source code tree. I've seen
  9. this in many projects for many years, but I've seen it discussed only rarely
  10. — so here we are!
  11. The contrib directory is used as an unorganized (or, at best, lightly organized)
  12. bin of various useful things **contrib**uted by the community around the
  13. software, but which is not necessarily a good candidate for being a proper part
  14. of the software. Things in contrib should not be wired into your build system,
  15. shouldn't be part of your automated testing, shouldn't be included in your
  16. documentation, and should not be installed with your packages. contrib entries
  17. are not supported by the maintainers, and are given only a light code review at
  18. the most. There is no guarantee whatsoever of workitude or maintenance for
  19. anything found in contrib.
  20. Nevertheless, it is often useful to have such a place to put various little
  21. scripts, config files, and so on, which provide a helpful leg-up for users
  22. hoping to integrate the software with some third-party product, configure it to
  23. fit nicely into an unusual environment, coax it into some unusual behavior, or
  24. whatever else the case may be. The idea is to provide a place to drop a couple
  25. of files which might save a future someone facing similar problems from doing
  26. all of the work themselves. Such people can contribute back small fixes or
  27. improvements, and the maintenance burden of such contributions lies entirely
  28. with the users.
  29. If the contributor wants to take on a greater maintenance burden, this kind of
  30. stuff is better suited to a standalone project, with its own issue tracking,
  31. releases, and so on. If you just wrote a little script and want somewhere to
  32. drop it so that others may find it useful, then contrib is the place for you.
  33. For a quick example, let's consult Sway's [contrib
  34. folder](https://github.com/swaywm/sway/tree/master/contrib):
  35. ```
  36. _incr_version
  37. autoname-workspaces.py
  38. grimshot
  39. grimshot.1
  40. grimshot.1.scd
  41. inactive-windows-transparency.py
  42. ```
  43. The `_incr_version` script is something that I use myself to help with preparing
  44. new releases. It is a tool useful only to maintainers, and therefore is not
  45. distributed with the project.
  46. Looking at `autoname-workspaces.py` next, from which we can see that the quality
  47. criteria is reduced for members of contrib — none of Sway's upstream code
  48. is written in Python, and the introduction of such a dependency would be
  49. controversial. This script automatically changes your workspace name based on
  50. what applications you're running in it — an interesting workflow, but
  51. quite different from the <abbr title="out-of-the-box">OOTB</abbr> experience.
  52. `grimshot` is a shell script which ties together many third-party programs
  53. (grim, slurp, wl-copy, jq, and notify-send) to make a convenient way of taking
  54. screenshots. Adding this upstream would introduce *a lot* of third-party
  55. dependencies for a minor convenience. This tool has had a bit more effort put
  56. into it: notice that a man page is provided as well. Because the contrib
  57. directory does not participate in the upstream build system, the contributor has
  58. also added a pre-compiled man page so that you can skip this step when
  59. installing it on your system.
  60. Last, we have `inactive-windows-transparency.py`, which is a script for making
  61. all windows other than your focused one semi-transparent. Some people may want
  62. this, but again, it's not really something we'd consider appropriate for the
  63. OOTB experience. Perfect for contrib!