diff --git a/examples/web/docusaurus_example.vsh b/examples/web/docusaurus_example.vsh index 36dafecb..dbca4ff1 100755 --- a/examples/web/docusaurus_example.vsh +++ b/examples/web/docusaurus_example.vsh @@ -1,20 +1,18 @@ #!/usr/bin/env -S v -n -w -gc none -cg -cc tcc -d use_openssl -enable-globals run import freeflowuniverse.herolib.web.docusaurus -import os -// Create a new docusaurus factory -mut ds := docusaurus.new( - path_build: '/tmp/docusaurus_build' - path_publish: '/tmp/docusaurus_publish' -)! +docusaurus.new(heroscript:' -// 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")! + !!docusaurus.define + path_build: "/tmp/docusaurus_build" + path_publish: "/tmp/docusaurus_publish" -// println(site) + !!docusaurus.add name:"tfgrid_docs" + git_url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/ebooks/tech" + git_root:"/tmp/code" + git_reset:1 -//next generates but doesn't do anything beyond -// site.generate()! + !!docusaurus.dev -site.dev()! + ')! \ No newline at end of file diff --git a/lib/core/playbook/readme.md b/lib/core/playbook/readme.md index c6b6a4e8..7c9b6a4e 100644 --- a/lib/core/playbook/readme.md +++ b/lib/core/playbook/readme.md @@ -57,9 +57,6 @@ the first one is the action, the rest are the params ```v import freeflowuniverse.herolib.core.playbook - - - mut plbook := playbook.new(text: "....")! ``` diff --git a/lib/web/docusaurus/README.md b/lib/web/docusaurus/README.md new file mode 100644 index 00000000..e94649a1 --- /dev/null +++ b/lib/web/docusaurus/README.md @@ -0,0 +1,92 @@ +## How to use Heroscript with Docusaurus + +You can use Heroscript to define and add content to your Docusaurus site. Below is an example: + +```heroscript + +!!docusaurus.define production:true, update:true + +!!docusaurus.add name:"my_local_docs" path:"./docs" + +!!docusaurus.add name:"tfgrid_docs" + git_url:"git_url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/ebooks/tech" + git_reset:true + git_pull:true +``` + +### `docusaurus.define` Arguments + +* `path_publish` (string): Path where the Docusaurus site will be published. Default is an empty string. +* `path_build` (string): Path where the Docusaurus site will be built. Default is an empty string. +* `production` (boolean): If set to `true`, the site will be built for production. Default is `false`. +* `update` (boolean): If set to `true`, the Docusaurus site will be updated. Default is `false`. + +if heroscript used then it will send that content to the Docusaurus play command so it could do the docusaurus add below... + +### `docusaurus.add` Arguments + +* `name` (string): Name of the Docusaurus site. Default is "main". +* `path` (string): Local path to the documentation content. Default is an empty string. +* `git_url` (string): Git URL of the documentation repository. Default is an empty string. +* `git_reset` (boolean): If set to `true`, the Git repository will be reset. Default is `false`. +* `git_pull` (boolean): If set to `true`, the Git repository will be pulled. Default is `false`. +* `git_root` (string): Root directory within the Git repository. Default is an empty string. +* `nameshort` (string): Short name for the Docusaurus site. Default is the value of `name`. +* `path_publish` (string): Path where this specific documentation will be published. Default is an empty string. +* `production` (boolean): If set to `true`, this documentation will be built for production. Default is `false`. +* `watch_changes` (boolean): If set to `true`, changes will be watched. Default is `true`. +* `update` (boolean): If set to `true`, this documentation will be updated. Default is `false`. +* `open` (boolean): If set to `true`, the Docusaurus site will be opened after generation. Default is `false`. +* `init` (boolean): If set to `true`, the Docusaurus site will be initialized. Default is `false`. + + +## called through code + +### with heroscript in code + +```v + +import freeflowuniverse.herolib.web.docusaurus + +docusaurus.new(heroscript:' + + //next is optional + !!docusaurus.define + path_build: "/tmp/docusaurus_build" + path_publish: "/tmp/docusaurus_publish" + + !!docusaurus.add name:"tfgrid_docs" + git_url:"https://git.threefold.info/tfgrid/docs_tfgrid4/src/branch/main/ebooks/tech" + git_root:"/tmp/code" + git_reset:1 + + !!docusaurus.dev + + ')! + +``` + + +### directly + +```v + +import freeflowuniverse.herolib.web.docusaurus + +// Create a new docusaurus factory +mut ds := docusaurus.new( + path_build: '/tmp/docusaurus_build' + path_publish: '/tmp/docusaurus_publish' +)! + +// 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) + +//next generates but doesn't do anything beyond +// site.generate()! + +site.dev()! + +``` \ No newline at end of file diff --git a/lib/web/docusaurus/play.v b/lib/web/docusaurus/play.v index e6703fe3..cee1bff2 100644 --- a/lib/web/docusaurus/play.v +++ b/lib/web/docusaurus/play.v @@ -1,4 +1,4 @@ -module doctree +module docusaurus import freeflowuniverse.herolib.core.playbook { PlayBook } import freeflowuniverse.herolib.ui.console @@ -36,6 +36,8 @@ pub fn play(args_ PlayArgs) ! { path_build: path_build production: production update: update + // heroscript: p.get_default('heroscript', "")! + // heroscript_path: p.get_default('heroscript_path', "")! )! } @@ -48,9 +50,30 @@ pub fn play(args_ PlayArgs) ! { git_reset:= p.get_default_false('git_reset') git_pull:= p.get_default_false('git_pull') - mut site:=ds.get(url:url,path:path,name:"atest")! + mut site:=ds.get( + name: name + nameshort: p.get_default('nameshort', name)! + path: path + git_url: git_url + git_reset: git_reset + git_root: p.get_default('git_root', "")! + git_pull: git_pull + path_publish: p.get_default('path_publish', "")! + production: p.get_default_false('production') + watch_changes: p.get_default_true('watch_changes') + update: p.get_default_false('update') + open: p.get_default_false('open') + init: p.get_default_false('init') + )! + + if plbook.exists_once(filter: 'docusaurus.dev'){ + + // site.dev()! + + } } + } \ No newline at end of file