FEniCS / dolfinx

Next generation FEniCS problem solving environment
https://fenicsproject.org
GNU Lesser General Public License v3.0
743 stars 178 forks source link

Add Python and Jupyter Notebook links to all demos #2579

Open jhale opened 1 year ago

jhale commented 1 year ago

Describe new/missing feature

Add downloads to Jupyter notebook and Python files for all demos:

Example:

https://docs.fenicsproject.org/dolfinx/main/python/demos/demo_mixed-poisson.html

Suggestion user interface

No response

AdityaRanjanPadhi commented 1 year ago

Hello, I am getting started with about open-source contributions and would like to work on this issue.

jhale commented 1 year ago

That would be great @AdityaRanjanPadhi !

Can you do it without the full stop at the end of the link, I did that but on reflection it looks odd.

RequieMa commented 8 months ago

Hi @jhale,

I am new to DolfinX and currently reading the demos. I have interest in contributing the project. May I ask where we should put the Jupyter notebook demos?

jhale commented 8 months ago

I would like some feedback from @jorgensd before proceeding.

The demos in Jupyter notebook form are already there after a documentation build.

cd python/doc/
python -m sphinx -W -b html source/ build/html/ # needs sphinx and various other utilities
cd source/demos
ls

The current demos contain a download link to the Python file

https://github.com/FEniCS/dolfinx/blob/main/python/demo/demo_biharmonic.py#L18

Instead of this, it would be nice to have a "Download .py" and "Download .ipynb" buttons (images in svg format) instead of text with links to download. So it would look something like:

# # Biharmonic equation
#
# This demo shows how to:
#
# - Solve a linear partial differential equation
# - Use a discontinuous Galerkin method
# - Solve a fourth-order differential equation
#
# [Some new markdown code for two download buttons]
RequieMa commented 8 months ago

Hi @jhale,

Do you mean something similar to this? image

(Saw at https://bleyerj.github.io/comet-fenicsx/intro/linear_elasticity/linear_elasticity.html)

jorgensd commented 8 months ago

@BillMaZengou I'm quite happy with the suggested change. I tested it locally:

# ```{admonition} Download sources
# :class: download
#
# * {download}`Python script <./demo_mixed-poisson.py>`
# * {download}`Jupyter notebook <./demo_mixed-poisson.ipynb>`
# ```

image