Skip to content

Commit

Permalink
Docs coming along
Browse files Browse the repository at this point in the history
  • Loading branch information
marsninja committed Sep 17, 2023
1 parent f47a5cf commit d5c2fca
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 5 deletions.
6 changes: 3 additions & 3 deletions examples/manual_code/circle.jac
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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); }
2 changes: 1 addition & 1 deletion examples/manual_code/circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 45 additions & 1 deletion support/jac-lang.org/docs/learn/learn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
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"
```
4 changes: 4 additions & 0 deletions support/jac-lang.org/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit d5c2fca

Please sign in to comment.