Anyone is welcome to submit a pull request regardless of whether or not they have read this document. The purpose of this document is simply to explain the contribution process and the internals of how Coconut works to make contributing easier.
If you are thinking about contributing to Coconut, please don’t hesitate to ask questions at Coconut’s Gitter! That includes any questions at all about contributing, including understanding the source code, figuring out how to implement a specific change, or just trying to figure out what needs to be done.
Contributing to Coconut is as simple as
make devwill automatically install the full Coconut developer environment.
constants.pyto install Coconut. Also reads
README.rstto generate the PyPI description.
parsefunctions as convenience utilities when using Coconut as a module. Documented in
main_run, the entry points for the
constants.pyinto a form
setup.pycan use, as well as checks for updates to Coconut’s dependencies.
root.pycreates and executes the part of Coconut’s header that normalizes Python built-ins across versions. Whenever you are writing a new file, you should always add
from coconut.root import *to ensure compatibility with different Python versions.
root.pyalso sets basic version-related constants.
logger, which is Coconut’s primary method of logging a message from anywhere.
ArgumentParserobject used to parse Coconut command-line arguments.
startmethod is the main entry point for the Coconut command-line utility.
Promptfor getting syntax-highlighted input, and
Runnerfor executing compiled Python.
Compiler, the class that actually compiles Coconut code.
grammar.pyto get all of the basic grammatical definitions, then extends them with all of the handlers that depend on the compiler’s options (e.g. the current
Compileralso does pre- and post-processing, including replacing strings with markers (pre-processing) and adding the header (post-processing).
Grammar, the class that specifies Coconut’s grammar in PyParsing. Coconut performs one-pass compilation by attaching “handlers” to specific grammar objects to transform them into compiled Python.
grammar.pycontains all basic (non-option-dependent) handlers.
getheader, which generates the header at the top of all compiled Coconut files.
Matcher, which handles the compilation of all Coconut pattern-matching, including
matchstatements, destructuring assignment, and pattern-matching functions.
make test, or a
pytestcommand to run a specific test, is necessary.
TestCasesubclasses that run all of the commands for testing the Coconut files in
--argwas passed when running the file.