Introducing Jupyter Notebooks in mkdocs¶
This notebook showcases very basic functionality of rendering your jupyter notebooks as tutorials inside your mkdocs documentation.
As part of the python project template, your notebooks will be executed AND rendered at document build time.
In [ ]:
Copied!
def sierpinsky(order: int) -> None:
"""Define a method that will create a Sierpinsky triangle of given order, and will print it out."""
triangles = ["*"]
for i in range(order):
spaces = " " * (2**i)
triangles = [spaces + triangle + spaces for triangle in triangles] + [
triangle + " " + triangle for triangle in triangles
]
print(f"Printing order {order} triangle")
print("\n".join(triangles))
def sierpinsky(order: int) -> None:
"""Define a method that will create a Sierpinsky triangle of given order, and will print it out."""
triangles = ["*"]
for i in range(order):
spaces = " " * (2**i)
triangles = [spaces + triangle + spaces for triangle in triangles] + [
triangle + " " + triangle for triangle in triangles
]
print(f"Printing order {order} triangle")
print("\n".join(triangles))
Then, call our method a few times. This will happen on the fly during notebook rendering.
In [ ]:
Copied!
for order in range(3):
sierpinsky(order)
for order in range(3):
sierpinsky(order)
In [ ]:
Copied!
sierpinsky(4)
sierpinsky(4)