This page provides guidance on how to contribute to DOLFINx. For information about how to get involved and how to get in touch with the developers, see our community page.

Adding a demo

The below instructions are for adding a Python demo program to DOLFINx. DOLFINx demo programs are written in reStructuredText, and converted to Python/C++ code using pylit. The process for C++ demos is similar. The documented demo programs are displayed at

Creating the demo program

  1. Create a directory for the demo under demo/documented/, e.g. demo/documented/foo/python/.

  2. Write the demo in reStructuredText (rst), with the actual code in ‘code blocks’ (see other demos for guidance). The demo file should be named

  3. Convert the rst file to to a Python file using pylit (pylit is distributed with DOLFINx in utils/pylit)


    This will create a file Test that the Python script can be run.

Adding the demo to the documentation system

  1. Add the demo to the list in doc/source/demos.rst.

  2. To check how the documentation will be displayed on the web, in doc/ run make html and open the file doc/build/html/index.html in a browser.

Make a pull request

  1. Create a git branch and add the file to the repository. Do not add the file.

  2. If there is no C++ version, edit test/regression/ to indicate that there is no C++ version of the demo.

  3. Make a pull request at for your demo to be considered for addition to DOLFINx. Add the file to the repository, but do not add the file.