mirror of https://github.com/dsrw/enu.git
Doc updates
This commit is contained in:
parent
ac34fad0bc
commit
990ad409e5
|
@ -1,32 +1,32 @@
|
|||
import nimibook
|
||||
|
||||
var book = init_book_with_toc:
|
||||
section "Introduction", "intro.nim":
|
||||
entry "Goals", "intro/goals.nim"
|
||||
entry "Demos", "intro/demos.nim"
|
||||
entry "Install or Build", "intro/building.nim"
|
||||
section "Introduction", "intro":
|
||||
entry "Goals", "intro/goals"
|
||||
entry "Demos", "intro/demos"
|
||||
entry "Install or Build", "intro/building"
|
||||
|
||||
section "Basics", "basics.nim":
|
||||
entry "Controls and Usage", "basics/controls.nim"
|
||||
entry "Programming", "basics/programming.nim"
|
||||
entry "Config", "basics/config.nim"
|
||||
section "Basics", "basics":
|
||||
entry "Controls and Usage", "basics/controls"
|
||||
entry "Programming", "basics/programming"
|
||||
entry "Config", "basics/config"
|
||||
|
||||
section "Coding Enu", "coding.nim":
|
||||
entry "Concepts", "coding/concepts.nim"
|
||||
entry "Commands", "coding/commands.nim"
|
||||
entry "Shorthand Commands", "coding/shorthand.nim"
|
||||
entry "Random Numbers", "coding/random_numbers.nim"
|
||||
section "Coding Enu", "coding":
|
||||
entry "Concepts", "coding/concepts"
|
||||
entry "Commands", "coding/commands"
|
||||
entry "Shorthand Commands", "coding/shorthand"
|
||||
entry "Random Numbers", "coding/random_numbers"
|
||||
|
||||
section "Action Loops", "action_loops.nim":
|
||||
entry "Actions", "action_loops/actions.nim"
|
||||
entry "Loops", "action_loops/loops.nim"
|
||||
entry "Arrows", "action_loops/arrows.nim"
|
||||
entry "Child Loops", "action_loops/child_loops.nim"
|
||||
entry "More About Action Loops", "action_loops/more.nim"
|
||||
section "Action Loops", "action_loops":
|
||||
entry "Actions", "action_loops/actions"
|
||||
entry "Loops", "action_loops/loops"
|
||||
entry "Arrows", "action_loops/arrows"
|
||||
entry "Child Loops", "action_loops/child_loops"
|
||||
entry "More About Action Loops", "action_loops/more"
|
||||
|
||||
section "Examples", "examples.nim":
|
||||
entry "Shapes", "example/shapes.nim"
|
||||
section "Examples", "examples":
|
||||
entry "Shapes", "example/shapes"
|
||||
|
||||
entry "TODO", "todo.nim"
|
||||
entry "TODO", "todo"
|
||||
|
||||
nimibook_cli(book)
|
||||
|
|
|
@ -38,7 +38,7 @@ However, at this point it's probably better to use a `proc`.
|
|||
|
||||
# Action Loops
|
||||
|
||||
*Note for Nimians: Action Loops are state machines, and any proc can be a state. If the proc has a return value it will
|
||||
*Note for Nimions: Action Loops are state machines, and any proc can be a state. If the proc has a return value it will
|
||||
be discarded.*
|
||||
|
||||
Action Loops can help control the complexity of the logic for your units. They allow you to run complicated lists of
|
||||
|
|
|
@ -12,27 +12,6 @@ body {
|
|||
}
|
||||
|
||||
.dark {
|
||||
normal: #F6F3E8;
|
||||
/*> .hljs {*/
|
||||
/* display: block;*/
|
||||
/* overflow-x: auto;*/
|
||||
/* background: blue;*/
|
||||
/* color: #e6e1cf;*/
|
||||
/* padding: 0.5em;*/
|
||||
/*}*/
|
||||
normal: #F6F3E8;
|
||||
comment: #7C7C7C;
|
||||
entity: #FFD2A7;
|
||||
keyword: #96CBFE;
|
||||
operator: #EDEDED;
|
||||
class: #FFFFB6;
|
||||
storage: #CFCB90;
|
||||
constant: #99CC99;
|
||||
text: #A8FF60;
|
||||
number: #FF73FD;
|
||||
variable: #C6C5FE;
|
||||
invalid: #FD5FF;
|
||||
|
||||
--bg: #0b0517;
|
||||
--fg: #F6F3E8;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ nb_text: """
|
|||
|
||||
# Commands
|
||||
|
||||
## `move/build`
|
||||
## `move` / `build`
|
||||
|
||||
When dealing with a `Build` unit, commands can do different things depending on whether the unit is in `build`
|
||||
mode or `move` mode. `move` mode moves the unit around, while `build` creates new blocks. By default a `Build` is in
|
||||
|
@ -42,7 +42,7 @@ up 5 # build 5 blocks up
|
|||
enemy.up 5 # move up 5
|
||||
```
|
||||
|
||||
## `forward/back/up/down/left/right`
|
||||
## `forward` / `back` / `up` / `down` / `left` / `right`
|
||||
|
||||
Move or build x number of blocks in the specified direction. Defaults to 1 block.
|
||||
|
||||
|
@ -60,7 +60,7 @@ Turn a unit. Can be passed:
|
|||
- a unit to turn towards. Ex. `turn player`
|
||||
- a negative unit to turn away from. Ex. `turn -player`
|
||||
|
||||
## `near(less_than = 5.0) / far(greater_than = 100.0)`
|
||||
## `near(less_than = 5.0)` / `far(greater_than = 100.0)`
|
||||
|
||||
Returns true or false if a unit is nearer/farther than the specified distance. For example:
|
||||
|
||||
|
@ -93,7 +93,7 @@ if player.hit(enemy1):
|
|||
echo "The player hit enemy1"
|
||||
```
|
||||
|
||||
## `position/postion=`
|
||||
## `position` / `postion=`
|
||||
|
||||
Gets or set the position of a unit as a Vector3. `me` by default.
|
||||
|
||||
|
@ -107,7 +107,7 @@ if player.hit(enemy):
|
|||
|
||||
The starting position of a unit. Missing currently, but will be in in 0.2.
|
||||
|
||||
## `speed/speed=`
|
||||
## `speed` / `speed=`
|
||||
|
||||
Gets or sets the speed of a unit. `me` by default.
|
||||
|
||||
|
@ -120,15 +120,15 @@ Switching between build and move mode doesn't impact the speed, except in the ca
|
|||
mode with a speed of 0. `speed = 0` is extremely common for build mode, but makes things appear broken in move mode,
|
||||
as nothing will actually move, so switching to move mode with a speed of 0 will automatically reset the speed to 1.
|
||||
|
||||
## `scale/scale=`
|
||||
## `scale` / `scale=`
|
||||
|
||||
Sets the scale/size of a unit. `me` by default.
|
||||
|
||||
## `glow/glow=`
|
||||
## `glow` / `glow=`
|
||||
|
||||
Specifies the glow/brightness of a unit. `me` by default. Currently does nothing for bots, but will in the future.
|
||||
|
||||
## `global/global=`
|
||||
## `global` / `global=`
|
||||
|
||||
Specifies if a unit is in global space, or the space of its parent. If `global = true` and the parent unit moves,
|
||||
child units are unaffected. If `global = false`, the child will move with its parent. Does nothing for top level units,
|
||||
|
@ -140,11 +140,11 @@ By default, new `Build` units are `global = false` and new `Bot` units are `glob
|
|||
|
||||
Gets the rotation of a unit as a Vector3.
|
||||
|
||||
## `velocity/velocity=`
|
||||
## `velocity` / `velocity=`
|
||||
|
||||
Gets or sets the velocity of a unit, as a Vector3. Currently buggy.
|
||||
|
||||
## `color/color=`
|
||||
## `color` / `color=`
|
||||
|
||||
Gets or sets a units color. `me` by default. For `Build` units, this only impacts blocks placed after the property
|
||||
is set. For `Bot` units this does nothing, but in the future it will change their color.
|
||||
|
@ -153,7 +153,7 @@ is set. For `Bot` units this does nothing, but in the future it will change thei
|
|||
|
||||
Bounces a unit in the air. Currently only works for the player.
|
||||
|
||||
## `save/restore`
|
||||
## `save` / `restore`
|
||||
|
||||
`Build` units only. `save` the position, direction, drawing state, and color of the draw point, to `restore` it later.
|
||||
Can optionally take a name string to enable saving/restoring multiple points.
|
||||
|
|
|
@ -15,7 +15,7 @@ or:
|
|||
forward 10
|
||||
turn_right()
|
||||
```
|
||||
![Square Example](/media/square_example.png)
|
||||
![Square Example](assets/square_example.png)
|
||||
Create a twisting tower:
|
||||
```nim
|
||||
var
|
||||
|
@ -33,7 +33,7 @@ height.times:
|
|||
turn 5
|
||||
up 1
|
||||
```
|
||||
![Tower Example](/media/tower_example.png)
|
||||
![Tower Example](assets/tower_example.png)
|
||||
|
||||
Draw randomly:
|
||||
```nim
|
||||
|
@ -44,7 +44,7 @@ forward 10
|
|||
turn -180..180
|
||||
up 0..2
|
||||
```
|
||||
![Random Example](/media/random_example.png)
|
||||
![Random Example](assets/random_example.png)
|
||||
|
||||
Set the color to blue randomly with a 1 in 50 chance. Otherwise set it to white:
|
||||
```nim
|
||||
|
@ -57,7 +57,7 @@ or as a one-liner:
|
|||
```nim
|
||||
color = if 1 in 50: blue else: white
|
||||
```
|
||||
![Random Color Example](/media/random_color_example.png)
|
||||
![Random Color Example](assets/random_color_example.png)
|
||||
|
||||
Move forward 10 times, cycling through colors:
|
||||
```nim
|
||||
|
@ -65,4 +65,4 @@ Move forward 10 times, cycling through colors:
|
|||
color = cycle(red, black, blue)
|
||||
forward 1
|
||||
```
|
||||
![Color Cycle Example](/media/cycle_example.png)
|
||||
![Color Cycle Example](assets/cycle_example.png)
|
||||
|
|
|
@ -8,14 +8,14 @@ nb_text: """
|
|||
|
||||
3D live coding, implemented in Nim.
|
||||
|
||||
![Enu Screenshot](/media/screenshot_2.png)
|
||||
![Enu Screenshot](assets/screenshot_3.webp)
|
||||
|
||||
Enu lets you build and explore worlds using a familiar block-building interface
|
||||
and a Logo inspired API. It aspires to make 3D development more accessible, and
|
||||
will eventually be usable to create standalone games.
|
||||
|
||||
***Note:*** *The docs for Enu 0.2 are a work in progress. Most of the core ideas are here, but a fair bit of revision is required. The 0.2 docs will be targeted
|
||||
towards new programmers, with 'Note for Nimians` sections aimed at more
|
||||
towards new programmers, with 'Note for Nimions` sections aimed at more
|
||||
experienced folks to explain what's really going on. However, things are all
|
||||
over the place right now, with the intended audience changing paragraph by
|
||||
paragraph.*
|
||||
|
|
|
@ -130,7 +130,12 @@
|
|||
|
||||
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
||||
<div class="sidebar-scrollbox">
|
||||
{{> toc }}<!-- I could use also an unescaped context value -->
|
||||
<ol class="chapter">
|
||||
<li>
|
||||
<a href="https://ē.nu" tabindex="0">Home</a>
|
||||
</li>
|
||||
</ol>
|
||||
{{> toc }}<!-- I could use also an unescaped context value -->
|
||||
</div>
|
||||
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
|
||||
</nav>
|
||||
|
|
|
@ -8,15 +8,15 @@ export pathutils, pretty
|
|||
const document* = hl_html static_read("./book/template.html.mustache")
|
||||
|
||||
proc use_enu*(doc: var NbDoc) =
|
||||
doc.context["path_to_root"] = doc.srcDirRel.string & "/" # I probably should make sure to have / at the end
|
||||
doc.context["path_to_root"] = doc.src_dir_rel.string & "/" # I probably should make sure to have / at the end
|
||||
|
||||
# templates are in memory
|
||||
doc.partials["document"] = document
|
||||
# if they need to be overriden a specific template folder should be created in nbSrcDir
|
||||
doc.templateDirs = @[doc.srcDir.string / "templates"]
|
||||
doc.template_dirs = @[doc.src_dir.string / "templates"]
|
||||
|
||||
# book.json is publicly accessible (sort of a public static api)
|
||||
let bookPath = doc.homeDir.string / "book.json"
|
||||
let book_path = doc.home_dir.string / "book.json"
|
||||
# load book object
|
||||
var book = load(bookPath)
|
||||
|
||||
|
@ -33,24 +33,24 @@ proc use_enu*(doc: var NbDoc) =
|
|||
doc.context["plausible_analytics_url"] = book.plausible_analytics_url
|
||||
doc.context["highlightJs"] = highlightJsTags
|
||||
|
||||
var thisEntry: Entry
|
||||
var this_entry: Entry
|
||||
# process toc
|
||||
for i, entry in enumerate(book.toc.entries.mitems):
|
||||
if normalizePath(entry.url) == normalizePath(doc.filename.replace('\\', '/')): # replace needed for windows
|
||||
thisEntry = entry
|
||||
entry.isActive = true
|
||||
if normalize_path(entry.url) == normalize_path(doc.filename.replace('\\', '/')): # replace needed for windows
|
||||
this_entry = entry
|
||||
entry.is_active = true
|
||||
let
|
||||
prevUrl = book.prevEntryUrl i
|
||||
nextUrl = book.nextEntryUrl i
|
||||
if prevUrl.len > 0:
|
||||
doc.context["previous"] = prevUrl
|
||||
if nextUrl.len > 0:
|
||||
doc.context["next"] = nextUrl
|
||||
prev_url = book.prev_entry_url i
|
||||
next_url = book.next_entry_url i
|
||||
if prev_url.len > 0:
|
||||
doc.context["previous"] = prev_url
|
||||
if next_url.len > 0:
|
||||
doc.context["next"] = next_url
|
||||
break
|
||||
doc.partials["toc"] = render book.toc
|
||||
|
||||
# html.head.title (what appears in the tab)
|
||||
doc.context["title"] = thisEntry.title & " - " & book.title
|
||||
doc.context["title"] = this_entry.title & " - " & book.title
|
||||
|
||||
template load_md*(file) =
|
||||
const text = static_read file
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
[nimib]
|
||||
src_dir = "book"
|
||||
home_dir = "build"
|
||||
home_dir = "../dist/docs"
|
||||
|
||||
[nimibook]
|
||||
language = "en-us"
|
||||
title = "Enu"
|
||||
description = "Build, together"
|
||||
description = "Build together"
|
||||
default_theme = "dark"
|
||||
preferred_dark_theme = "dark"
|
||||
git_repository_url = "https://github.com/dsrw/enu"
|
||||
favicon_escaped = """<link rel="icon" type="image/svg+xml" href="data:image/svg+xml,%3Csvg width='100' height='100' viewBox='0 0 100 100' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='filter1' x='0' y='0' width='100' height='100' filterUnits='userSpaceOnUse' primitiveUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='5.664063'/%3E%3CfeOffset dx='2.336994' dy='0.992622' result='offsetblur'/%3E%3CfeFlood flood-color='%23000000' flood-opacity='0.5'/%3E%3CfeComposite in2='offsetblur' operator='in'/%3E%3CfeMerge%3E%3CfeMergeNode/%3E%3CfeMergeNode in='SourceGraphic'/%3E%3C/feMerge%3E%3C/filter%3E%3Cpath id='Shape' fill='%23000000' fill-rule='evenodd' stroke='%23180019' stroke-width='0.976563' stroke-linecap='round' filter='url(%23filter1)' d='M 77.34375 10.890625 L 81.15625 12.5 L 84.453125 14.96875 L 87.03125 18.125 L 88.859375 21.921875 L 89.609375 25.140625 L 89.75 72.578125 L 88.828125 78.109375 L 86.078125 83.21875 L 81.84375 87.046875 L 77.359375 89.078125 L 73.03125 89.734375 L 27.390625 89.75 L 24.296875 89.46875 L 21.09375 88.5625 L 18.125 87.046875 L 15.53125 85.015625 L 13.40625 82.546875 L 11.765625 79.703125 L 10.671875 76.46875 L 10.25 72.65625 L 10.25 27.421875 L 11.15625 21.875 L 13.90625 16.765625 L 18.125 12.9375 L 21.078125 11.421875 L 23.46875 10.6875 L 26.9375 10.25 L 73.03125 10.25 Z'/%3E%3Cfilter id='filter2' x='0' y='0' width='100' height='100' filterUnits='userSpaceOnUse' primitiveUnits='userSpaceOnUse' color-interpolation-filters='sRGB'%3E%3CfeGaussianBlur stdDeviation='0.326347'/%3E%3C/filter%3E%3Cpath id='path1' fill='%23ffffff' fill-rule='evenodd' stroke='none' filter='url(%23filter2)' d='M 64.036942 21.978188 L 64.036942 15.817451 L 36.556816 15.817451 L 36.556816 21.978188 Z M 61.19976 65.670776 C 60.105419 69.278046 56.173897 71.507263 50.945377 71.507263 C 43.974018 71.507263 39.47506 66.724586 39.47506 59.266853 L 39.47506 57.280827 L 69.10334 57.280827 L 69.10334 52.49815 C 69.10334 39.933491 62.091446 32.313629 50.540066 32.313629 C 39.069748 32.313629 31.490421 39.974022 31.490421 51.606464 L 31.490421 58.334637 C 31.490421 70.899292 38.583374 78.194901 50.985909 78.194901 C 60.510731 78.194901 67.806343 73.087982 68.981743 65.670776 Z M 50.459003 38.960743 C 57.146645 38.960743 61.118698 43.702888 61.118698 51.565933 L 39.47506 51.565933 C 39.47506 43.662357 43.609238 38.960743 50.459003 38.960743 Z'/%3E%3C/svg%3E%0A" />"""
|
||||
|
|
16
enu.nimble
16
enu.nimble
|
@ -345,8 +345,14 @@ task dist, "Build distribution":
|
|||
dist_package_task()
|
||||
|
||||
task docs, "Build docs":
|
||||
cd "docs"
|
||||
exec "rm -rf build"
|
||||
exec "nim r book.nim init"
|
||||
exec "nim r book.nim build"
|
||||
exec "cp -r book/assets build"
|
||||
exec "rm -rf dist/docs"
|
||||
with_dir "docs":
|
||||
exec "nim r book.nim init"
|
||||
exec "nim r book.nim build"
|
||||
exec "cp -r docs/book/assets dist/docs"
|
||||
exec "cp media/*.{png,webp} dist/docs/assets"
|
||||
|
||||
task export_docs, "Build docs and copy them to ../enu-site/docs":
|
||||
docs_task()
|
||||
exec "rm -rf ../enu-site/docs"
|
||||
exec "cp -r dist/docs ../enu-site"
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 182 KiB |
Loading…
Reference in New Issue