Multiple Projects

Awdur allows for multiple code projects to be embedded within a single documentation artifact. Where relevant awdur's directives accept a :project: option that allow you to specify which project it should be assoicated with.

The awdur:project-tree directive accepts a project name as an argument.

Hello World

Where no project name is given, the name default will be used as... well, the default.

hello.py

print("Hello, World!")

The code below is a valid "Hello, World!" application in Python.

hello.py
print("Hello, World!")

Shapes

This project deals with geometric shapes

rectangle.el

;;; rectangle.el --- Description

(defun rectangle-area (w h)
  (* w h))

(defun rectangle-perimeter (w h)
  (* 2 (+ w h))

(provide 'rectangle)
triangle.el

;;; triangle.el --- Description

(defun triangle-area (a b c)
  (* 0.5 a b))

(defun triangle-perimeter (a b c)
  (+ a b c))

(provide 'triangle)

Setup

The following template is used when defining an elisp module in this project.

elisp-module
{% extends "default" %}

{% block header %};;; {{ path.name }} --- Description

{% endblock %}

{% block footer %}

(provide '{{ path.stem }}){% endblock %}

Triangles

The code block below defines a function to compute the area of a triangle.

triangle.el
(defun triangle-area (a b c)
  (* 0.5 a b))

And this defines a function to compute the perimeter, note that now we've the template once we don't need to repeat it.

triangle.el
(defun triangle-perimeter (a b c)
  (+ a b c))

Rectangles

The following code deals with rectangles.

rectangle.el
(defun rectangle-area (w h)
  (* w h))

(defun rectangle-perimeter (w h)
  (* 2 (+ w h))

Math

This project deals with number sequences

fib.py

def fib(n):
    if n == 0 or n == 1:
        return n
    return fib(n-1) + fib(n - 2)

nums = [str(fib(n)) for n in range(1, 11)]
print(f"The first 10 Fibonacci numbers are: {', '.join(nums)}")
square.py

def square(n):
    return n * n

nums = [str(square(n)) for n in range(1,11)]
print(f"The first 10 square numbers are: {', '.join(nums)}")

Fibbonacci

Below is a function to calculate the nth Fibonacci number

fib.py
def fib(n):
    if n == 0 or n == 1:
        return n
    return fib(n-1) + fib(n - 2)

Which we can then use to print the first 10 Fibonacci numbers

fib.py
nums = [str(fib(n)) for n in range(1, 11)]
print(f"The first 10 Fibonacci numbers are: {', '.join(nums)}")

Square Numbers

Here is a function for calculating the square of a number

square.py
def square(n):
    return n * n

Which we can then use to print the first 10 square numbers

square.py
nums = [str(square(n)) for n in range(1,11)]
print(f"The first 10 square numbers are: {', '.join(nums)}")