start implementing docusaurus bizmodel exporting

This commit is contained in:
timurgordon
2025-02-18 05:09:56 +03:00
parent 2317dd2d4c
commit 5e468359a1
5 changed files with 122 additions and 20 deletions

59
lib/biz/bizmodel/export.v Normal file
View File

@@ -0,0 +1,59 @@
module bizmodel
import freeflowuniverse.herolib.web.docusaurus
pub struct Export {
pub:
build_path string
format ExportFormat
}
pub enum ExportFormat {
mdbook
docusaurus
}
pub fn (b BizModel) export(export Export) ! {
match export.format {
.docusaurus {b.export_docusaurus(export)}
.mdbook {panic('MDBook export not fully implemented')}
}
}
pub fn (b BizModel) export_docusaurus(export Export) ! {
factory := docusaurus.new(
build_path: export.build_path
)
// b.export_summary()
// b.export_business_description()
// b.export_market_analysis()
// b.export_business_model()
b.export_revenue_model(export)
b.export_cost_structure(export)
b.export_operational_plan(export)!
b.export_fundraising(export)
}
pub fn (b BizModel) export_operational_plan(export Export) ! {
mut hr_page := pathlib.get_file(path: '${export.build_path}/human_resources.md')
hr_page.template_write()
for employee in b.employees {
mut employee_page := pathlib.get_file(path: '${export.build_path}/${texttools.snake_case(employee.name)}.md')!
employee_page.template_write(employee.md)!
}
}
pub fn (b BizModel) export_revenue_model(export Export) ! {
mut overview_page := pathlib.get_file(path: '${export.build_path}/revenue_overview.md')
overview_page.template_write()
mut overview_page := pathlib.get_file(path: '${export.build_path}/revenue_overview.md')
overview_page.template_write()
for employee in b.employees {
mut employee_page := pathlib.get_file(path: '${export.build_path}/${texttools.snake_case(employee.name)}.md')!
employee_page.template_write(employee.md)!
}
}

View File

@@ -2,53 +2,48 @@
## FUNDING
!!bizmodel.sheet_wiki includefilter:'funding'
@{bizmodel.sheet.wiki(includefilter:'funding')!}
## REVENUE vs COGS
!!bizmodel.sheet_wiki includefilter:rev
@{bizmodel.sheet.wiki(includefilter:'rev')!}
#### Revenue Lines
!!bizmodel.sheet_wiki title:'Revenue Total' includefilter:'revtotal'
@{bizmodel.sheet.wiki(title:'Revenue Total', includefilter:'revtotal')!}
#### COGS Lines
!!bizmodel.sheet_wiki title:'COGS' includefilter:'cogstotal'
@{bizmodel.sheet.wiki(title:'COGS', includefilter:'cogstotal')!}
## HR
!!bizmodel.sheet_wiki title:'HR Teams' includefilter:'hrnr'
!!bizmodel.sheet_wiki title:'HR Costs' includefilter:'hrcost'
@{bizmodel.sheet.wiki(title:'HR Teams', includefilter:'hrnr')!}
@{bizmodel.sheet.wiki(title:'HR Costs', includefilter:'hrcost')!}
## Operational Costs
!!bizmodel.sheet_wiki title:'COSTS' includefilter:'ocost'
@{bizmodel.sheet.wiki(title:'COSTS', includefilter:'ocost')!}
## P&L Overview
<!-- period is in months, 3 means every quarter -->
!!bizmodel.sheet_wiki title:'P&L Overview' includefilter:'pl'
@{bizmodel.sheet.wiki(title:'P&L Overview', includefilter:'pl')!}
!!bizmodel.graph_bar_row rowname:revenue_total unit:million title:'A Title' title_sub:'Sub'
@{bizmodel.graph_bar_row(rowname:'revenue_total', unit:'million', title:'A Title', title_sub:'Sub')!}
Unit is in Million USD.
!!bizmodel.graph_bar_row rowname:revenue_total unit:million
@{bizmodel.graph_bar_row(rowname:'revenue_total', unit:'million')!}
!!bizmodel.graph_line_row rowname:revenue_total unit:million
!!bizmodel.graph_pie_row rowname:revenue_total unit:million size:'80%'
@{bizmodel.graph_line_row(rowname:'revenue_total', unit:'million')!}
@{bizmodel.graph_pie_row(rowname:'revenue_total', unit:'million', size:'80%')!}
## Some Details
> show how we can do per month
!!bizmodel.sheet_wiki includefilter:'pl' period_months:1
@{bizmodel.sheet_wiki(includefilter:'pl', period_months:1)!}

View File

@@ -34,6 +34,7 @@ pub mut:
check bool = true // means will check the dir, link or file exists
empty bool // will empty the dir or the file
delete bool
increment bool // will increment filename until free name available (filename1...)
}
// get a directory, or needs to be created
@@ -81,6 +82,15 @@ pub fn get_file(args_ GetArgs) !Path {
mut p2 := get_no_check(args.path)
if args.check {
p2.check()
if args.increment {
if p2.exists() {
incr := if args.path[args.path.len-1].is_digit() {
args.path[args.path.len-1].ascii_str().int()
} else {0}
return get_file(GetArgs {...args, path: '${args.path}${incr}'})
}
}
if args.create {
mut parent_ := p2.parent()!
parent_.check()

View File

@@ -0,0 +1,38 @@
module texttools
pub fn snake_case(s string) string {
return separate_words(s).join('_')
}
pub fn title_case(s string) string {
return separate_words(s).join(' ').title()
}
pub fn pascal_case(s string) string {
mut pascal := s.replace('_', ' ')
return pascal.title().replace(' ', '')
}
pub fn camel_case(s string) string {
return pascal_case(s).uncapitalize()
}
const separators = ['.', '_', '-', '/', ' ', ':', ',', ';']
fn separate_words(s string) []string {
mut words := []string{}
mut word := ''
for i, c in s {
if (c.is_capital() || c.ascii_str() in separators) && word != '' {
words << word.to_lower()
word = ''
}
if c.ascii_str() !in separators {
word += c.ascii_str().to_lower()
}
}
if word != '' {
words << word.to_lower()
}
return words
}

View File

@@ -42,4 +42,4 @@ pub fn new(args_ DocusaurusArgs) !&DocusaurusFactory {
ds.template_install(args.update)!
return ds
}
}