...
This commit is contained in:
@@ -12,7 +12,7 @@ mut ds := docusaurus.new(
|
||||
// mut site:=ds.get(path:"${os.home_dir()}/code/git.threefold.info/tfgrid/docs_tfgrid4/ebooks/tech",name:"atest")!
|
||||
mut site:=ds.get(url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/ebooks/tech",name:"atest")!
|
||||
|
||||
println(site)
|
||||
// println(site)
|
||||
|
||||
//next generates but doesn't do anything beyond
|
||||
// site.generate()!
|
||||
|
||||
@@ -66,6 +66,21 @@ my_collection/
|
||||
|
||||
Markdown files (`.md`) are treated as pages.
|
||||
|
||||
## use Play
|
||||
|
||||
```heroscript
|
||||
|
||||
!!doctree.collection name:"my_local_docs" path:"./docs"
|
||||
|
||||
!!doctree.collection name:"tfgrid_docs"
|
||||
git_url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/collections"
|
||||
git_reset: true
|
||||
git_pull: true
|
||||
|
||||
//is optional, if not specified then will be at ${os.home_dir()}/hero/var/doctree/main
|
||||
!!doctree.export name: "my_local_docs", destination: "/tmp/1" exclude_errors:0 reset:1
|
||||
```
|
||||
|
||||
## Redis Structure
|
||||
|
||||
when using the export redis:true argument, which is default
|
||||
|
||||
@@ -4,11 +4,12 @@ import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.data.doctree.collection { Collection }
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.core.texttools.regext
|
||||
import os
|
||||
|
||||
@[params]
|
||||
pub struct TreeExportArgs {
|
||||
pub mut:
|
||||
destination string @[required]
|
||||
destination string
|
||||
reset bool = true
|
||||
keep_structure bool // wether the structure of the src collection will be preserved or not
|
||||
exclude_errors bool // wether error reporting should be exported as well
|
||||
@@ -20,14 +21,19 @@ pub mut:
|
||||
// export all collections to chosen directory .
|
||||
// all names will be in name_fixed mode .
|
||||
// all images in img/
|
||||
pub fn (mut tree Tree) export(args TreeExportArgs) ! {
|
||||
console.print_header('export tree: name:${tree.name} to ${args.destination}')
|
||||
pub fn (mut tree Tree) export(args_ TreeExportArgs) ! {
|
||||
mut args:= args_
|
||||
if args.toreplace.len > 0 {
|
||||
mut ri := regext.regex_instructions_new()
|
||||
ri.add_from_text(args.toreplace)!
|
||||
tree.replacer = ri
|
||||
}
|
||||
|
||||
if args.destination.len == 0 {
|
||||
args.destination = '${os.home_dir()}/hero/var/doctree/main'
|
||||
}
|
||||
console.print_header('export tree: name:${tree.name} to ${args.destination}')
|
||||
|
||||
mut dest_path := pathlib.get_dir(path: args.destination, create: true)!
|
||||
if args.reset {
|
||||
dest_path.empty()!
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
module doctree
|
||||
|
||||
import freeflowuniverse.herolib.core.playbook { PlayBook }
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
|
||||
|
||||
@[params]
|
||||
pub struct PlayArgs {
|
||||
pub mut:
|
||||
heroscript string // if filled in then plbook will be made out of it
|
||||
heroscript string
|
||||
heroscript_path string
|
||||
plbook ?PlayBook
|
||||
reset bool
|
||||
@@ -22,7 +24,7 @@ pub fn play(args_ PlayArgs) ! {
|
||||
collection_actions := plbook.find(filter: 'doctree.collection')!
|
||||
for action in collection_actions {
|
||||
mut p := action.params
|
||||
name := p.get('name')!
|
||||
name := p.get_default('name',"main")!
|
||||
mut doctree := doctrees[name] or {
|
||||
mut newdtr:= doctree.new(name: name)!
|
||||
doctrees[name] = newdtr
|
||||
@@ -36,18 +38,24 @@ pub fn play(args_ PlayArgs) ! {
|
||||
|
||||
}
|
||||
|
||||
|
||||
if collection_actions.len==0 {
|
||||
return error("No collections configured, use !!doctree.collection...")
|
||||
}
|
||||
|
||||
export_actions := plbook.find(filter: 'doctree.export')!
|
||||
if export_actions.len == 0 {
|
||||
name0:="main"
|
||||
mut doctree0 := doctrees[name0] or { panic("can't find doctree with name ${name0}") }
|
||||
doctree0.export()!
|
||||
}
|
||||
for action in export_actions {
|
||||
mut p := action.params
|
||||
name := p.get('name')!
|
||||
name := p.get_default('name',"main")!
|
||||
destination := p.get('destination')!
|
||||
reset:= p.get_default_false('reset')
|
||||
exclude_errors:= p.get_default_false('exclude_errors')
|
||||
mut doctree := doctrees[name] or {
|
||||
mut newdtr:= doctree.new(name: name)!
|
||||
doctrees[name] = newdtr
|
||||
newdtr
|
||||
}
|
||||
exclude_errors:= p.get_default_true('exclude_errors')
|
||||
mut doctree := doctrees[name] or { return error("can't find doctree with name ${name}") }
|
||||
doctree.export(
|
||||
destination: destination
|
||||
reset: reset
|
||||
|
||||
@@ -7,6 +7,7 @@ import freeflowuniverse.herolib.develop.gittools
|
||||
import freeflowuniverse.herolib.web.siteconfig
|
||||
import freeflowuniverse.herolib.ui.console
|
||||
import freeflowuniverse.herolib.osal
|
||||
import freeflowuniverse.herolib.data.doctree
|
||||
|
||||
@[params]
|
||||
pub struct DSiteGetArgs {
|
||||
@@ -37,6 +38,8 @@ pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite {
|
||||
args.path = gs.get_path(url: args.url)!
|
||||
}
|
||||
|
||||
|
||||
|
||||
if args.path.trim_space() == '' {
|
||||
args.path = os.getwd()
|
||||
}
|
||||
@@ -85,6 +88,11 @@ pub fn (mut f DocusaurusFactory) get(args_ DSiteGetArgs) !&DocSite {
|
||||
args.path_publish = "${f.path_publish}/${args.name}"
|
||||
}
|
||||
|
||||
doctree.play(
|
||||
heroscript_path: configpath
|
||||
reset: args.update
|
||||
)!
|
||||
|
||||
mut mysiteconfig:=*siteconfig.new(configpath)!
|
||||
|
||||
mut ds := DocSite{
|
||||
|
||||
@@ -2,6 +2,7 @@ module docusaurus
|
||||
|
||||
import os
|
||||
import freeflowuniverse.herolib.core.pathlib
|
||||
import freeflowuniverse.herolib.data.doctree
|
||||
|
||||
@[heap]
|
||||
pub struct DocusaurusFactory {
|
||||
@@ -20,8 +21,8 @@ pub mut:
|
||||
path_build string
|
||||
production bool
|
||||
update bool
|
||||
// heroscript string
|
||||
// heroscript_path string
|
||||
heroscript string
|
||||
heroscript_path string
|
||||
}
|
||||
|
||||
pub fn new(args_ DocusaurusArgs) !&DocusaurusFactory {
|
||||
@@ -41,6 +42,5 @@ pub fn new(args_ DocusaurusArgs) !&DocusaurusFactory {
|
||||
}
|
||||
|
||||
f.template_install(install: args.update, template_update: args.update)!
|
||||
|
||||
return f
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user