Skip to content

Commit 77314a0

Browse files
committed
Add a two-module task manager example
task-manager.plain requires task-model.plain, demonstrating a requires dependency chain: the base module is rendered first and the top module builds on top of its generated code.
1 parent eb810dc commit 77314a0

4 files changed

Lines changed: 97 additions & 0 deletions

File tree

examples/task-manager/README.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Two-module task manager example
2+
3+
This example is split into two modules to demonstrate a `requires` dependency chain:
4+
5+
- **`task-model.plain`** — the base module. Defines `:Task:`, `:TaskList:`, and `:User:`,
6+
implements the entry point, adding a task, and showing the task list. It exports its
7+
concepts so downstream modules can build on them.
8+
- **`task-manager.plain`** — the top module. It `requires` `task-model`, inheriting its
9+
generated code and functional specs as a starting point, then adds deleting, editing,
10+
and completing tasks.
11+
12+
Rendering `task-manager.plain` builds `task-model` first, then continues on top of it.
13+
14+
# How to render the example
15+
16+
You can run the example with the `codeplain` command:
17+
18+
```bash
19+
codeplain task-manager.plain
20+
```
21+
22+
# How to run the generated code
23+
24+
After the rendering is finished, you can run the generated software code using the command:
25+
26+
```bash
27+
python3 dist/taskmgr.py
28+
```
29+
30+
See [top-level README](../../README.md) for additional information and help for troubleshooting the examples.

examples/task-manager/config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
unittests-script: ../../test_scripts/run_unittests_python.sh
2+
conformance-tests-script: ../../test_scripts/run_conformance_tests_python.sh
3+
copy-build: true
4+
build-dest: dist
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
description: 'A task manager application — extends the task model with editing features'
3+
import:
4+
- python-console-app-template # spec source available at https://github.com/Codeplain-ai/codeplain/blob/main/standard_template_library/
5+
requires:
6+
- task-model
7+
---
8+
9+
***implementation reqs***
10+
11+
- :MainExecutableFile: of :App: should be called "taskmgr.py".
12+
13+
***test reqs***
14+
> Test requirements are defined in 'python-console-app-template'.
15+
16+
***functional specs***
17+
18+
- :User: should be able to delete :Task:
19+
20+
- :User: should be able to edit :Task:
21+
22+
- :User: should be able to mark :Task: as completed.
23+
24+
25+
26+
> see https://www.plainlang.org/ for more information on ***plain
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
description: 'Core task model — base module providing tasks and a task list'
3+
import:
4+
- python-console-app-template # spec source available at https://github.com/Codeplain-ai/codeplain/blob/main/standard_template_library/
5+
exported_concepts: [":User:", ":Task:", ":TaskList:"]
6+
---
7+
8+
***definitions***
9+
10+
- :User: is the user of :App:
11+
12+
- :Task: describes an activity that needs to be done by :User:. :Task: has the following attributes
13+
- Name - a short description of :Task:. This is a required attribute. The name must be at least 3 characters long.
14+
- Notes - additional details about :Task:
15+
- Due Date - optional date by which :User: is supposed to complete :Task:.
16+
17+
- :TaskList: is a list of :Task: items.
18+
- Initially :TaskList: should be empty.
19+
20+
***implementation reqs***
21+
22+
- :MainExecutableFile: of :App: should be called "taskmgr.py".
23+
24+
***test reqs***
25+
> Test requirements are defined in 'python-console-app-template'.
26+
27+
***functional specs***
28+
29+
- Implement the entry point for :App:.
30+
31+
- :User: should be able to add :Task:. Only valid :Task: items can be added.
32+
33+
- Show :TaskList:
34+
35+
36+
37+
> see https://www.plainlang.org/ for more information on ***plain

0 commit comments

Comments
 (0)