From d5c2fca835f873560b53160ee8506f7ca1a75ed1 Mon Sep 17 00:00:00 2001 From: marsninja Date: Sun, 17 Sep 2023 12:27:04 -0400 Subject: [PATCH] Docs coming along --- examples/manual_code/circle.jac | 6 ++-- examples/manual_code/circle.py | 2 +- support/jac-lang.org/docs/learn/learn.md | 46 +++++++++++++++++++++++- support/jac-lang.org/mkdocs.yml | 4 +++ 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/examples/manual_code/circle.jac b/examples/manual_code/circle.jac index 9db482df7..69c470469 100644 --- a/examples/manual_code/circle.jac +++ b/examples/manual_code/circle.jac @@ -1,5 +1,6 @@ """ -This module demonstrates a simple circle class and a function to calculate the area of a circle. +This module demonstrates a simple circle class and a function to calculate +the area of a circle in all of Jac's glory. """ import:py math; @@ -57,9 +58,8 @@ with entry:__main__ { # TODO: add name == option abstract feature print(f"Area of a {c.shape_type.value} with radius {RAD} using class: {c.area()}"); } - +# Unit Tests! global expected_area = 78.53981633974483; - test calculate_area { check.AlmostEqual(calculate_area(RAD), expected_area); } test circle_area { c = Circle(RAD); check.AlmostEqual(c.area(), expected_area); } test circle_type { c = Circle(RAD); check.Equal(c.shape_type, ShapeType.CIRCLE); } \ No newline at end of file diff --git a/examples/manual_code/circle.py b/examples/manual_code/circle.py index 9558123bb..68b6f76a6 100644 --- a/examples/manual_code/circle.py +++ b/examples/manual_code/circle.py @@ -62,7 +62,7 @@ def area(self) -> float: # run_tests() -# Unit tests below, bad practice in python to have unit tests in the same file as the code +# Unit Tests! class TestShapesFunctions(unittest.TestCase): def test_calculate_area(self): expected_area = 78.53981633974483 diff --git a/support/jac-lang.org/docs/learn/learn.md b/support/jac-lang.org/docs/learn/learn.md index 0ecd65b44..959974be1 100644 --- a/support/jac-lang.org/docs/learn/learn.md +++ b/support/jac-lang.org/docs/learn/learn.md @@ -21,4 +21,48 @@ If that command prints `hello world`, Jac is working. Ok now lets jump into learning Jac! ## Modules in Jac -We start this journey top down. Lets look at a simple but complete program in python and the Jac version. \ No newline at end of file +We start this journey top down. Lets look at a simple but complete program in python and the Jac version. + +=== "Jac (circle.jac)" + ```jac linenums="1" + --8<-- "examples/manual_code/circle.jac" + ``` +=== "Python (circle.py)" + ```python linenums="1" + --8<-- "examples/manual_code/circle.py" + ``` + +Now lets break it down! + +### Docstrings, Imports, and Globals + +=== "circle.jac" + ```jac linenums="1" + --8<-- "examples/manual_code/circle.jac::8" + ``` +=== "circle.py" + ```python linenums="1" + --8<-- "examples/manual_code/circle.py::10" + ``` + +### Functions / Abilities + +=== "circle.jac" + ```jac linenums="10" + --8<-- "examples/manual_code/circle.jac:10:13" + ``` +=== "circle.py" + ```python linenums="13" + --8<-- "examples/manual_code/circle.py:13:15" + ``` + +### Multiline Comments + +=== "circle.jac" + ```jac linenums="15" + --8<-- "examples/manual_code/circle.jac:15:18" + ``` +=== "circle.py" + ```python linenums="18" + --8<-- "examples/manual_code/circle.py:18:22" + ``` \ No newline at end of file diff --git a/support/jac-lang.org/mkdocs.yml b/support/jac-lang.org/mkdocs.yml index ad165c01a..4e93e1657 100644 --- a/support/jac-lang.org/mkdocs.yml +++ b/support/jac-lang.org/mkdocs.yml @@ -46,12 +46,16 @@ theme: - navigation.path markdown_extensions: + - pymdownx.tabbed: + alternate_style: true - pymdownx.highlight: anchor_linenums: true line_spans: __span pygments_lang_class: true pygments_style: 'autumn' - pymdownx.inlinehilite + # - codehilite: + # linenums: true - pymdownx.snippets: base_path: ['.', '../../'] - pymdownx.superfences: