This commit is contained in:
2025-08-12 10:36:26 +02:00
parent 4cd5b51085
commit 6b46b3dbaa
30 changed files with 472 additions and 747 deletions

View File

@@ -46,7 +46,7 @@ pub fn (mut site DocSite) generate() ! {
mut aa := site.path_src.dir_get('docs')!
aa.copy(dest: '${f.path_build.path}/docs', delete: true)!
}
mut main_file := pathlib.get_file(path: '${cfg_path}/main.json', create: true)!
main_file.write(json.encode_pretty(site.config.main))!
@@ -56,11 +56,10 @@ pub fn (mut site DocSite) generate() ! {
mut footer_file := pathlib.get_file(path: '${cfg_path}/footer.json', create: true)!
footer_file.write(json.encode_pretty(site.config.footer))!
// Generate the actual docs content from the processed site configuration
docs_path := '${f.path_build.path}/docs'
//TODO: check site vs website
// TODO: check site vs website
website := site.website
generate_docs(
path: docs_path
@@ -72,11 +71,12 @@ pub fn (mut site DocSite) generate() ! {
pub fn (mut site DocSite) process_imports() ! {
mut gs := gittools.new()!
mut f:=factory_get()!
mut f := factory_get()!
for item in site.website.siteconfig.imports {
if true{panic("not implemented import")}
if true {
panic('not implemented import')
}
mypath := gs.get_path(
pull: false
@@ -88,7 +88,7 @@ pub fn (mut site DocSite) process_imports() ! {
mypatho.copy(dest: '${f.path_build.path}/docs/${item.dest}', delete: false)!
println(item)
//replace: {'NAME': 'MyName', 'URGENCY': 'red'}
// replace: {'NAME': 'MyName', 'URGENCY': 'red'}
mut ri := regext.regex_instructions_new()
for key, val in item.replace {
ri.add_item('\{${key}\}', val)!

View File

@@ -8,8 +8,6 @@ import freeflowuniverse.herolib.web.site
import freeflowuniverse.herolib.ui.console
import freeflowuniverse.herolib.osal.core as osal
@[params]
pub struct AddArgs {
pub mut:
@@ -71,7 +69,7 @@ pub fn dsite_add(args_ AddArgs) !&DocSite {
// Get the site object after processing, this is the website which is a generic definition of a site
mut website := site.get(name: args.sitename)!
// Create the DocSite instance
mut dsite := &DocSite{
name: args.sitename

View File

@@ -15,7 +15,7 @@ mut:
client &doctreeclient.DocTreeClient
flat bool // if flat then won't use sitenames as subdir's
site Site
errors []string // collect errors here
errors []string // collect errors here
}
@[params]
@@ -23,7 +23,7 @@ struct SiteGeneratorArgs {
mut:
path string
flat bool // if flat then won't use sitenames as subdir's
site Site //this is the generic website we are feeding
site Site // this is the generic website we are feeding
}
// Generate docs from site configuration
@@ -51,16 +51,13 @@ pub fn generate_docs(args SiteGeneratorArgs) ! {
if gen.errors.len > 0 {
return error('Errors occurred during site generation:\n${gen.errors.join('\n\n')}\nPlease fix the errors and try again.\nPage List: is header collection and page name per collection.\nAvailable pages:\n${gen.client.list_markdown()!}')
}
}
fn (mut mysite SiteGenerator) error( msg string) ! {
fn (mut mysite SiteGenerator) error(msg string) ! {
console.print_stderr('Error: ${msg}')
mysite.errors << msg
}
fn (mut mysite SiteGenerator) page_generate(args_ Page) ! {
mut args := args_
@@ -69,7 +66,7 @@ fn (mut mysite SiteGenerator) page_generate(args_ Page) ! {
mut parts := args.src.split(':')
if parts.len != 2 {
mysite.error("Invalid src format for page '${args.src}', expected format: collection:page_name, TODO: fix in ${args.path}, check the collection & page_name exists in the pagelist")!
return
return
}
collection_name := parts[0]
page_name := parts[1]
@@ -129,7 +126,7 @@ fn (mut mysite SiteGenerator) page_generate(args_ Page) ! {
c += '\n${page_content}\n'
if args.path.ends_with('/') || args.path.trim_space()=="" {
if args.path.ends_with('/') || args.path.trim_space() == '' {
// means is dir
args.path += page_name
}

View File

@@ -4,7 +4,6 @@ import freeflowuniverse.herolib.core.playbook { PlayBook }
import freeflowuniverse.herolib.web.site
pub fn play(mut plbook PlayBook) ! {
if !plbook.exists(filter: 'docusaurus.') {
return
}
@@ -36,9 +35,9 @@ pub fn play(mut plbook PlayBook) ! {
dsite_add(
sitename: site_name
path: p.get_default('path', '')!
git_url: p.get_default('git_url','')!
git_url: p.get_default('git_url', '')!
git_reset: p.get_default_false('git_reset')
git_root: p.get_default('git_root','')!
git_root: p.get_default('git_root', '')!
git_pull: p.get_default_false('git_pull')
path_publish: p.get_default('path_publish', f.path_publish.path)!
)!