dolfinx icon indicating copy to clipboard operation
dolfinx copied to clipboard

Add Python and Jupyter Notebook links to all demos

Open jhale opened this issue 2 years ago • 7 comments

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

jhale avatar Mar 10 '23 08:03 jhale

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

AdityaRanjanPadhi avatar Mar 12 '23 09:03 AdityaRanjanPadhi

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.

jhale avatar Mar 15 '23 14:03 jhale

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?

RequieMa avatar Jan 17 '24 02:01 RequieMa

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]

jhale avatar Jan 17 '24 10:01 jhale

Hi @jhale,

Do you mean something similar to this? image

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

RequieMa avatar Jan 21 '24 08:01 RequieMa

@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

jorgensd avatar Jan 21 '24 13:01 jorgensd