refactor: overhaul Docusaurus command and generation

- Rework `hero docusaurus` command to use local `cfg` files
- Scan and export doctree collections during site generation
- Fix `baseUrl` redirect path handling in `index.tsx`
- Add cycle detection for `play.include` in playbooks
- Improve site config processing to prevent duplicate items
This commit is contained in:
Mahmoud-Emad
2025-08-07 10:46:57 +03:00
parent 2667856633
commit 82a46e8149
15 changed files with 291 additions and 140 deletions

View File

@@ -40,18 +40,20 @@ pub fn (action Action) str() string {
// serialize to heroscript
pub fn (action Action) heroscript() string {
mut out := ''
if action.comments.len > 0 {
out += texttools.indent(action.comments, '// ')
}
if action.comments.len > 0 {
// out += texttools.indent(action.comments, '// ')
}
if action.actiontype == .dal {
out += '!'
} else if action.actiontype == .sal {
out += '!!'
} else if action.actiontype == .wal {
out += '!!!!'
} else if action.actiontype == .macro {
out += '!!!'
} else {
panic('only action sal and macro supported for now')
panic('unsupported action type: ${action.actiontype}')
}
if action.actor != '' {

View File

@@ -8,13 +8,13 @@ import crypto.blake2b
@[heap]
pub struct PlayBook {
pub mut:
actions []&Action
actions []&Action @[skip; str: skip]
priorities map[int][]int // first key is the priority, the list of int's is position in list self.actions
othertext string // in case there is text outside of the actions
result string // if any result
nractions int
done []int // which actions did we already find/run?
session &base.Session
session &base.Session @[skip; str: skip]
}
@[params]

View File

@@ -89,7 +89,8 @@ pub fn (mut plbook PlayBook) add(args_ PlayBookNewArgs) ! {
if state == .comment_for_action_maybe {
if line.starts_with('//') {
comments << line_strip.trim_left('/ ')
comment_content := line_strip.trim_left('/ ')
comments << comment_content
} else {
if line_strip.starts_with('!') {
// we are at end of comment
@@ -150,7 +151,8 @@ pub fn (mut plbook PlayBook) add(args_ PlayBookNewArgs) ! {
continue
} else if line.starts_with('//') {
state = .comment_for_action_maybe
comments << line_strip.trim_left('/ ')
comment_content := line_strip.trim_left('/ ')
comments << comment_content
// } else {
// plbook.othertext += '${line_strip}\n'
}