Skip to content

Commit

Permalink
add more docs
Browse files Browse the repository at this point in the history
  • Loading branch information
elpham6 authored and elpham6 committed May 9, 2024
1 parent c3285e8 commit 34f6ddb
Show file tree
Hide file tree
Showing 9 changed files with 262 additions and 0 deletions.
Binary file added docs/auto_examples/auto_examples_jupyter.zip
Binary file not shown.
Binary file added docs/auto_examples/auto_examples_python.zip
Binary file not shown.
43 changes: 43 additions & 0 deletions docs/auto_examples/calc_example.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Calculator Example\n\nThis is some example code using functions from the calculator module.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import os\nimport sys\nsys.path.insert(0, os.path.abspath(\"../src\"))\nfrom calculator import sum, subtract, multiply, divide\n\n# Example numbers for operations\nnumber1 = 8\nnumber2 = 2\n\n# Using the sum function to add two numbers\nresult_addition = sum(number1, number2)\nprint(f\"The sum of {number1} and {number2} is {result_addition}.\")\n\n# Using the subtract function to subtract the second number from the first\nresult_subtraction = subtract(number1, number2)\nprint(f\"The result of subtracting {number2} from {number1} is {result_subtraction}.\")\n\n# Using the multiply function to multiply two numbers\nresult_multiplication = multiply(number1, number2)\nprint(f\"The product of {number1} and {number2} is {result_multiplication}.\")\n\n# Using the divide function to divide the first number by the second\ntry:\n result_division = divide(number1, number2)\n print(f\"The quotient of {number1} divided by {number2} is {result_division}.\")\nexcept ZeroDivisionError:\n print(\"Cannot divide by zero.\")\n\n# Attempt to divide by zero to demonstrate error handling\ntry:\n zero_division_test = divide(number1, 0)\nexcept ZeroDivisionError:\n print(\"An error occurred: cannot divide by zero.\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.5"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
40 changes: 40 additions & 0 deletions docs/auto_examples/calc_example.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
"""
Calculator Example
##################
This is some example code using functions from the calculator module.
"""
import os
import sys
sys.path.insert(0, os.path.abspath("../src"))
from calculator import sum, subtract, multiply, divide

# Example numbers for operations
number1 = 8
number2 = 2

# Using the sum function to add two numbers
result_addition = sum(number1, number2)
print(f"The sum of {number1} and {number2} is {result_addition}.")

# Using the subtract function to subtract the second number from the first
result_subtraction = subtract(number1, number2)
print(f"The result of subtracting {number2} from {number1} is {result_subtraction}.")

# Using the multiply function to multiply two numbers
result_multiplication = multiply(number1, number2)
print(f"The product of {number1} and {number2} is {result_multiplication}.")

# Using the divide function to divide the first number by the second
try:
result_division = divide(number1, number2)
print(f"The quotient of {number1} divided by {number2} is {result_division}.")
except ZeroDivisionError:
print("Cannot divide by zero.")

# Attempt to divide by zero to demonstrate error handling
try:
zero_division_test = divide(number1, 0)
except ZeroDivisionError:
print("An error occurred: cannot divide by zero.")
83 changes: 83 additions & 0 deletions docs/auto_examples/calc_example.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@

.. DO NOT EDIT.
.. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY.
.. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE:
.. "auto_examples/calc_example.py"
.. LINE NUMBERS ARE GIVEN BELOW.
.. only:: html

.. note::
:class: sphx-glr-download-link-note

:ref:`Go to the end <sphx_glr_download_auto_examples_calc_example.py>`
to download the full example code

.. rst-class:: sphx-glr-example-title

.. _sphx_glr_auto_examples_calc_example.py:


Calculator Example
##################

This is some example code using functions from the calculator module.

.. GENERATED FROM PYTHON SOURCE LINES 8-40
.. code-block:: Python
import os
import sys
sys.path.insert(0, os.path.abspath("../src"))
from calculator import sum, subtract, multiply, divide
# Example numbers for operations
number1 = 8
number2 = 2
# Using the sum function to add two numbers
result_addition = sum(number1, number2)
print(f"The sum of {number1} and {number2} is {result_addition}.")
# Using the subtract function to subtract the second number from the first
result_subtraction = subtract(number1, number2)
print(f"The result of subtracting {number2} from {number1} is {result_subtraction}.")
# Using the multiply function to multiply two numbers
result_multiplication = multiply(number1, number2)
print(f"The product of {number1} and {number2} is {result_multiplication}.")
# Using the divide function to divide the first number by the second
try:
result_division = divide(number1, number2)
print(f"The quotient of {number1} divided by {number2} is {result_division}.")
except ZeroDivisionError:
print("Cannot divide by zero.")
# Attempt to divide by zero to demonstrate error handling
try:
zero_division_test = divide(number1, 0)
except ZeroDivisionError:
print("An error occurred: cannot divide by zero.")
.. _sphx_glr_download_auto_examples_calc_example.py:

.. only:: html

.. container:: sphx-glr-footer sphx-glr-footer-example

.. container:: sphx-glr-download sphx-glr-download-jupyter

:download:`Download Jupyter notebook: calc_example.ipynb <calc_example.ipynb>`

.. container:: sphx-glr-download sphx-glr-download-python

:download:`Download Python source code: calc_example.py <calc_example.py>`


.. only:: html

.. rst-class:: sphx-glr-signature

`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
Binary file added docs/auto_examples/calc_example_codeobj.pickle
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
59 changes: 59 additions & 0 deletions docs/auto_examples/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
:orphan:

Calculator Examples
###################

This folder contains example code for the **calculator.py** module.


.. raw:: html

<div class="sphx-glr-thumbnails">


.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="This is some example code using functions from the calculator module.">

.. only:: html

.. image:: /auto_examples/images/thumb/sphx_glr_calc_example_thumb.png
:alt:

:ref:`sphx_glr_auto_examples_calc_example.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">Calculator Example</div>
</div>


.. raw:: html

</div>


.. toctree::
:hidden:

/auto_examples/calc_example


.. only:: html

.. container:: sphx-glr-footer sphx-glr-footer-gallery

.. container:: sphx-glr-download sphx-glr-download-python

:download:`Download all examples in Python source code: auto_examples_python.zip </auto_examples/auto_examples_python.zip>`

.. container:: sphx-glr-download sphx-glr-download-jupyter

:download:`Download all examples in Jupyter notebooks: auto_examples_jupyter.zip </auto_examples/auto_examples_jupyter.zip>`


.. only:: html

.. rst-class:: sphx-glr-signature

`Gallery generated by Sphinx-Gallery <https://sphinx-gallery.github.io>`_
37 changes: 37 additions & 0 deletions docs/auto_examples/sg_execution_times.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

:orphan:

.. _sphx_glr_auto_examples_sg_execution_times:


Computation times
=================
**00:00.000** total execution time for 1 file **from auto_examples**:

.. container::

.. raw:: html

<style scoped>
<link href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.3.0/css/bootstrap.min.css" rel="stylesheet" />
<link href="https://cdn.datatables.net/1.13.6/css/dataTables.bootstrap5.min.css" rel="stylesheet" />
</style>
<script src="https://code.jquery.com/jquery-3.7.0.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/jquery.dataTables.min.js"></script>
<script src="https://cdn.datatables.net/1.13.6/js/dataTables.bootstrap5.min.js"></script>
<script type="text/javascript" class="init">
$(document).ready( function () {
$('table.sg-datatable').DataTable({order: [[1, 'desc']]});
} );
</script>

.. list-table::
:header-rows: 1
:class: table table-striped sg-datatable

* - Example
- Time
- Mem (MB)
* - :ref:`sphx_glr_auto_examples_calc_example.py` (``calc_example.py``)
- 00:00.000
- 0.0

0 comments on commit 34f6ddb

Please sign in to comment.