From 69ecca004b7c3eb4d575bd7e68932fb517088010 Mon Sep 17 00:00:00 2001 From: mrpye Date: Fri, 28 Jul 2023 00:22:55 +0100 Subject: [PATCH] v0.1.4 --- .gitignore | 2 +- README.md | 59 +++-- cmd/root.go | 78 +++++- code_gen/code_gen_engine.go | 136 ++++++---- code_gen/schema_data.go | 12 + code_gen/schema_template.go | 119 ++++++++- {docs => documents}/img/app_accelerator.png | Bin .../img/app_accelerator_code_style.png | Bin .../img/app_accelerator_features.png | Bin .../img/app_accelerator_nav.png | Bin .../img/app_accelerator_net_version.png | Bin .../img/app_accelerator_pages.png | Bin {docs => documents}/img/app_shell.png | Bin .../img/configure_maui_app.png | Bin {docs => documents}/img/generated_code.png | Bin {docs => documents}/img/maui_program.png | Bin {docs => documents}/img/new_project.png | Bin .../img/project_add_person.png | Bin {docs => documents}/img/project_folder.png | Bin .../img/project_list_person.png | Bin {docs => documents}/img/project_menu.png | Bin {docs => documents}/img/solution_explorer.png | Bin {docs => documents}/maui-gen.md | 3 +- {docs => documents}/maui-gen_about.md | 2 +- {docs => documents}/maui-gen_build.md | 2 +- {docs => documents}/maui-gen_completion.md | 2 +- .../maui-gen_completion_bash.md | 2 +- .../maui-gen_completion_fish.md | 2 +- .../maui-gen_completion_powershell.md | 2 +- .../maui-gen_completion_zsh.md | 2 +- {docs => documents}/maui-gen_gen_docs.md | 2 +- documents/maui-gen_gen_template_docs.md | 30 +++ {docs => documents}/maui-gen_init.md | 2 +- {docs => documents}/maui-gen_init_all.md | 2 +- {docs => documents}/maui-gen_init_examples.md | 2 +- .../maui-gen_init_templates.md | 2 +- {docs => documents}/maui-gen_nuget.md | 2 +- {docs => documents}/maui-gen_nuget_install.md | 2 +- {docs => documents}/maui-gen_set.md | 2 +- {docs => documents}/maui-gen_set_edit.md | 2 +- {docs => documents}/maui-gen_set_output.md | 2 +- {docs => documents}/maui-gen_set_schema.md | 2 +- {docs => documents}/maui-gen_set_template.md | 2 +- examples/person_and_pet.yaml | 4 +- lib/lib_helper.go | 9 +- templates/Interfaces/IModel_Template.cs | 4 +- templates/Views/EditPage_Template.xaml | 78 +----- templates/Views/Editors.xml | 76 ++++++ templates/template_document.md | 73 ++++++ templates/template_document_list.md | 6 + templates/templates.yaml | 237 +++++++++++++++++- 51 files changed, 770 insertions(+), 194 deletions(-) rename {docs => documents}/img/app_accelerator.png (100%) rename {docs => documents}/img/app_accelerator_code_style.png (100%) rename {docs => documents}/img/app_accelerator_features.png (100%) rename {docs => documents}/img/app_accelerator_nav.png (100%) rename {docs => documents}/img/app_accelerator_net_version.png (100%) rename {docs => documents}/img/app_accelerator_pages.png (100%) rename {docs => documents}/img/app_shell.png (100%) rename {docs => documents}/img/configure_maui_app.png (100%) rename {docs => documents}/img/generated_code.png (100%) rename {docs => documents}/img/maui_program.png (100%) rename {docs => documents}/img/new_project.png (100%) rename {docs => documents}/img/project_add_person.png (100%) rename {docs => documents}/img/project_folder.png (100%) rename {docs => documents}/img/project_list_person.png (100%) rename {docs => documents}/img/project_menu.png (100%) rename {docs => documents}/img/solution_explorer.png (100%) rename {docs => documents}/maui-gen.md (84%) rename {docs => documents}/maui-gen_about.md (86%) rename {docs => documents}/maui-gen_build.md (90%) rename {docs => documents}/maui-gen_completion.md (94%) rename {docs => documents}/maui-gen_completion_bash.md (94%) rename {docs => documents}/maui-gen_completion_fish.md (93%) rename {docs => documents}/maui-gen_completion_powershell.md (92%) rename {docs => documents}/maui-gen_completion_zsh.md (94%) rename {docs => documents}/maui-gen_gen_docs.md (88%) create mode 100644 documents/maui-gen_gen_template_docs.md rename {docs => documents}/maui-gen_init.md (93%) rename {docs => documents}/maui-gen_init_all.md (88%) rename {docs => documents}/maui-gen_init_examples.md (88%) rename {docs => documents}/maui-gen_init_templates.md (88%) rename {docs => documents}/maui-gen_nuget.md (86%) rename {docs => documents}/maui-gen_nuget_install.md (86%) rename {docs => documents}/maui-gen_set.md (92%) rename {docs => documents}/maui-gen_set_edit.md (83%) rename {docs => documents}/maui-gen_set_output.md (85%) rename {docs => documents}/maui-gen_set_schema.md (85%) rename {docs => documents}/maui-gen_set_template.md (85%) create mode 100644 templates/Views/Editors.xml create mode 100644 templates/template_document.md create mode 100644 templates/template_document_list.md diff --git a/.gitignore b/.gitignore index 27579d3..6c97b49 100644 --- a/.gitignore +++ b/.gitignore @@ -15,7 +15,7 @@ answer*.yaml # vendor/ /output -/documents + config.json /export.zip diff --git a/README.md b/README.md index 3168ac8..ff6d54a 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ First you will need to create a new project in Visual Studio using the **MAUI Ap Open **Visual Studio** and create a new project this will start the project selection menu. -![New Project](docs/img/new_project.png) +![New Project](documents/img/new_project.png) @@ -109,7 +109,7 @@ Select the **MAUI App Accelerator** to start the project wizard. -![App Accelerator](docs/img/app_accelerator.png) +![App Accelerator](documents/img/app_accelerator.png) @@ -124,7 +124,7 @@ Enter the project name and solution name. -![Configure Project](docs/img/configure_maui_app.png) +![Configure Project](documents/img/configure_maui_app.png) @@ -137,7 +137,7 @@ Select the .NET version to use either .Net 6 or .NET 7. -![.Net Version](docs/img/app_accelerator_net_version.png) +![.Net Version](documents/img/app_accelerator_net_version.png) @@ -150,7 +150,7 @@ Select the MVVM Toolkit -![Code Style](docs/img/app_accelerator_code_style.png) +![Code Style](documents/img/app_accelerator_code_style.png) @@ -163,7 +163,7 @@ You can select Flyout or Tabs -![Navigation](docs/img/app_accelerator_nav.png) +![Navigation](documents/img/app_accelerator_nav.png) @@ -176,7 +176,7 @@ You can just click next on the pages. -![Pages](docs/img/app_accelerator_pages.png) +![Pages](documents/img/app_accelerator_pages.png) @@ -191,7 +191,7 @@ Add the following libraries: -![Features](docs/img/app_accelerator_features.png) +![Features](documents/img/app_accelerator_features.png) @@ -204,7 +204,7 @@ MAUI App Accelerator will create the project -![Solution Explorer](docs/img/solution_explorer.png) +![Solution Explorer](documents/img/solution_explorer.png) @@ -225,7 +225,7 @@ MAUI App Accelerator will create the project - You will need to add this to the file **AppShell.xaml.cs** -![AppShell](docs/img/app_shell.png) +![AppShell](documents/img/app_shell.png) - Add the comment just below the InitializeComponent and save changes. ```c# public partial class AppShell : Shell @@ -257,7 +257,7 @@ public partial class AppShell : Shell ``` - You will need to add this to the file **AppShell.xaml.cs** -![MauiProgram](docs/img/maui_program.png) +![MauiProgram](documents/img/maui_program.png) - Add the comment just below the **builder.Services.AddSingleton @@ -455,10 +455,23 @@ You can now simple run the project and you should see. --- ## Documents - -* [maui-gen CLI documents](docs/maui-gen.md) +[maui-gen CLI documents](./documents/maui-gen.md) +```bash +# Run maui-get to build template documents +maui-gen gen_docs +``` +You can find the generated documents here. +* C:\Users\[User]\.maui-gen\documents\maui-gen.md + +```bash +# Run maui-get to build template documents +maui-gen gen_template_docs +``` +You can find the generated template documents here. +* C:\Users\[User]\.maui-gen\template_doc/Templates.md + --- ## Examples @@ -467,13 +480,13 @@ You can now simple run the project and you should see. Example Pictures @@ -503,7 +516,9 @@ This is just a proof of concept to see if it draws any attention if it does then ### v0.1.3 - Added nuget package install cmd - +### v0.1.4 +- Added template function to inject other templates +- Added Template Auto Generating documentation **maui-gen gen_template_docs** --- ## License diff --git a/cmd/root.go b/cmd/root.go index ca36a7c..356fb8c 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -7,8 +7,10 @@ import ( "fmt" "log" "os" + "path" "strings" + "github.com/Mrpye/maui-gen/code_gen" "github.com/Mrpye/maui-gen/lib" "github.com/spf13/cobra" "github.com/spf13/cobra/doc" @@ -27,10 +29,14 @@ Example Command: - maui-gen gen_docs `, RunE: func(cmd *cobra.Command, args []string) error { - if !lib.DirExists("./documents") { - os.MkdirAll("./documents", os.ModePerm) + + home_dir := lib.UserHomeDir() + maui_path := path.Join(home_dir, ".maui-gen", "documents") + + if !lib.DirExists(maui_path) { + os.MkdirAll(maui_path, os.ModePerm) } - err := doc.GenMarkdownTree(rootCmd, "./documents") + err := doc.GenMarkdownTree(rootCmd, maui_path) if err != nil { log.Fatal(err) } @@ -42,6 +48,69 @@ Example Command: return cmd } +func GenerateTemplateDoc() *cobra.Command { + var template_path string + var cmd = &cobra.Command{ + Use: "gen_template_docs", + Short: "This command will build the documents for the templates", + Long: ` +Description: +This command will build the documents for the templates + +Example Command: +- maui-gen gen_template_docs + `, + RunE: func(cmd *cobra.Command, args []string) error { + //************* + //Template Path + //************* + + if template_path == "" { + template_path = viper.GetString("templates") + if template_path == "" { + template_path = "./templates" + } + } + if !lib.DirExists(template_path) || !lib.FileExists(path.Join(template_path, "templates.yaml")) { + return fmt.Errorf("the path %s is not a valid template directory, make sure you are pointing to a directory where templates exist", template_path) + } + //************************ + //Create the output folder + //************************ + home_dir := lib.UserHomeDir() + template_doc_path := path.Join(home_dir, ".maui-gen", "template_doc") + + if !lib.DirExists(template_doc_path) { + os.MkdirAll(template_doc_path, os.ModePerm) + } + + //*********************************** + //create out instance of the code gen + //*********************************** + maui_gen, err := code_gen.Create("") + if err != nil { + return err + } + + //***************** + //Generate the code + //***************** + template_file_path := path.Join(template_path, "templates.yaml") + doc_template_path := path.Join(template_path, "template_document.md") + doc_template_menu_path := path.Join(template_path, "template_document_list.md") + err = maui_gen.BuildTemplateDocs(template_file_path, doc_template_path, doc_template_menu_path, template_doc_path) + if err != nil { + return err + } + + lib.ActionLogOK("Documents Generated", '-') + return nil + }, + } + cmd.Flags().StringVarP(&template_path, "templates", "t", "", "template path") + return cmd +} + func rootCmd_About() *cobra.Command { var cmd = &cobra.Command{ Use: "about", @@ -51,7 +120,7 @@ func rootCmd_About() *cobra.Command { lib.ActionLog("About", '-') fmt.Println("Author: Andrew Pye") - fmt.Println("Version: 0.1.3") + fmt.Println("Version: 0.1.4") fmt.Println("License: Apache") return nil }, @@ -88,6 +157,7 @@ func init() { SetupConfig() rootCmd.AddCommand(rootCmd_About()) rootCmd.AddCommand(GenerateDoc()) + rootCmd.AddCommand(GenerateTemplateDoc()) // Here you will define your flags and configuration settings. // Cobra supports persistent flags, which, if defined here, diff --git a/code_gen/code_gen_engine.go b/code_gen/code_gen_engine.go index 67b0f5f..a259fc0 100644 --- a/code_gen/code_gen_engine.go +++ b/code_gen/code_gen_engine.go @@ -16,6 +16,8 @@ import ( type CodeGen struct { Output_folder string + template_path string + current_data *Data Templates []Template requited_resources map[string]Template } @@ -136,8 +138,8 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err if ns != "" { s.ProjectNameSpace = ns } - - current_data := &Data{ + m.template_path = template_path + m.current_data = &Data{ RootNS: s.ProjectNameSpace, RootSchema: s, } @@ -150,10 +152,11 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err //Get the template for the data model //*********************************** template_results := m.GetTemplates(o.Templates) + m.current_data.Templates = &template_results for _, t := range template_results { fmt.Printf("Processing template %s for schema %s\n", t.TemplateFile, o.Name) - current_data.AddNamespace(t.NameSpace) + m.current_data.AddNamespace(t.NameSpace) //***************** //Load the template //***************** @@ -165,28 +168,28 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err //************************************* //Build the data model for the template //************************************* - current_data.Template = &t - current_data.Schema = &o + m.current_data.Template = &t + m.current_data.Schema = &o //************************* //Parse the register params //************************* - result_singleton_register, err := parseTemplate(t.RegisterSingleton, current_data) + result_singleton_register, err := m.parseTemplate(t.RegisterSingleton, m.current_data) if err != nil { return err } - current_data.AddSingleton(result_singleton_register) + m.current_data.AddSingleton(result_singleton_register) - result_route_register, err := parseTemplate(t.RegisterRoute, current_data) + result_route_register, err := m.parseTemplate(t.RegisterRoute, m.current_data) if err != nil { return err } - current_data.AddRoute(result_route_register) + m.current_data.AddRoute(result_route_register) //****************** //Parse the template //****************** - result, err := parseTemplate(tpl, current_data) + result, err := m.parseTemplate(tpl, m.current_data) if err != nil { return err } @@ -194,7 +197,7 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err //********************* //Parse the output path //********************* - new_path, err := parseTemplate(t.Output, current_data) + new_path, err := m.parseTemplate(t.Output, m.current_data) if err != nil { return err } @@ -227,7 +230,7 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err }) for _, r := range res_list { - current_data.AddNamespace(r.NameSpace) + m.current_data.AddNamespace(r.NameSpace) } //********************* //Process the Resources @@ -242,30 +245,30 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err if err != nil { return err } - current_data.RootNS = s.ProjectNameSpace - current_data.Template = &r - current_data.RootSchema = s - current_data.Schema = nil + m.current_data.RootNS = s.ProjectNameSpace + m.current_data.Template = &r + m.current_data.RootSchema = s + m.current_data.Schema = nil //************************* //Parse the register params //************************* - result_singleton_register, err := parseTemplate(r.RegisterSingleton, current_data) + result_singleton_register, err := m.parseTemplate(r.RegisterSingleton, m.current_data) if err != nil { return err } - current_data.AddSingleton(result_singleton_register) + m.current_data.AddSingleton(result_singleton_register) - result_route_register, err := parseTemplate(r.RegisterRoute, current_data) + result_route_register, err := m.parseTemplate(r.RegisterRoute, m.current_data) if err != nil { return err } - current_data.AddRoute(result_route_register) + m.current_data.AddRoute(result_route_register) //****************** //Parse the template //****************** - result, err := parseTemplate(tpl, current_data) + result, err := m.parseTemplate(tpl, m.current_data) if err != nil { return err } @@ -273,7 +276,7 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err //********************* //Parse the output path //********************* - new_path, err := parseTemplate(r.Output, current_data) + new_path, err := m.parseTemplate(r.Output, m.current_data) if err != nil { return err } @@ -340,37 +343,72 @@ func (m *CodeGen) Build(template_path string, schema_path string, ns string) err return nil } -func parseTemplate(tpl string, data *Data) (string, error) { +func (m *CodeGen) LoadTemplate(template string) string { + //***************** + //Read the template + //***************** + tpl, _ := lib.ReadFileToString(template) + + result, _ := m.parseTemplate(tpl, m.current_data) + return result +} + +func (m *CodeGen) LoadFieldTemplate(template string, data Field) string { + //***************** + //Read the template + //***************** + tpl, err := lib.ReadFileToString(template) + if err != nil { + panic(err) + } + m.current_data.Data = data + result, err := m.parseTemplate(tpl, m.current_data) + if err != nil { + panic(err) + } + return result +} + +func (m *CodeGen) BuildTemplatePath(file string) string { + return path.Join(m.template_path, file) +} + +func (m *CodeGen) parseTemplate(tpl string, data *Data) (string, error) { //********************* //Create a function map //********************* funcMap := template.FuncMap{ - "base64enc": lib.Base64EncString, - "base64dec": lib.Base64DecString, - "gzip_base64": lib.GzipBase64, - "lc": strings.ToLower, - "uc": strings.ToUpper, - "domain": lib.GetDomainOrIP, - "port_string": lib.GetPortString, - "port_int": lib.GetPortInt, - "clean": lib.Clean, - "concat": lib.Concat, - "replace": strings.ReplaceAll, - "contains": lib.StringContainsStringListItem, - "not": lib.NOT, - "or": lib.OR, - "and": lib.AND, - "plus": lib.Plus, - "minus": lib.Minus, - "multiply": lib.Multiply, - "divide": lib.Divide, - "camel": strcase.ToCamel, - "pub_var_name": lib.PubVarName, - "priv_var_name": lib.PrivVarName, - - "func_name": lib.FuncName, - "safe": lib.SafeName, - "display": lib.DisplayName, + "tpl_path": m.BuildTemplatePath, + "load_tpl": m.LoadTemplate, + "load_field_tpl": m.LoadFieldTemplate, + "path_base": path.Base, + "get_templates": data.GetTemplates, + "base64enc": lib.Base64EncString, + "base64dec": lib.Base64DecString, + "gzip_base64": lib.GzipBase64, + "lc": strings.ToLower, + "uc": strings.ToUpper, + "domain": lib.GetDomainOrIP, + "port_string": lib.GetPortString, + "port_int": lib.GetPortInt, + "clean": lib.Clean, + "concat": lib.Concat, + "replace": strings.ReplaceAll, + "contains": lib.StringContainsStringListItem, + "not": lib.NOT, + "or": lib.OR, + "and": lib.AND, + "plus": lib.Plus, + "minus": lib.Minus, + "multiply": lib.Multiply, + "divide": lib.Divide, + "camel": strcase.ToCamel, + "pub_var_name": lib.PubVarName, + "priv_var_name": lib.PrivVarName, + "na": lib.NA, + "func_name": lib.FuncName, + "safe": lib.SafeName, + "display": lib.DisplayName, } //***************** diff --git a/code_gen/schema_data.go b/code_gen/schema_data.go index 44d4c63..b2fb1f8 100644 --- a/code_gen/schema_data.go +++ b/code_gen/schema_data.go @@ -6,12 +6,24 @@ import ( type Data struct { RootNS string + Templates *[]Template Template *Template RootSchema *RootSchema Schema *Schema NameSpaces map[string]string RegisterSingleton map[string]string RegisterRoute map[string]string + Data Field +} + +func (m *Data) GetTemplates(template_name string) []Template { + result := []Template{} + for _, t := range *m.Templates { + if strings.EqualFold(t.Name, template_name) { + result = append(result, t) + } + } + return result } func (m *Data) AddNamespace(value string) { diff --git a/code_gen/schema_template.go b/code_gen/schema_template.go index 4546434..30b2120 100644 --- a/code_gen/schema_template.go +++ b/code_gen/schema_template.go @@ -1,15 +1,112 @@ package code_gen +import ( + "fmt" + "path" + + "github.com/Mrpye/maui-gen/lib" +) + type Template struct { - Name string `json:"name" yaml:"name"` - TemplateFile string `json:"template_file" yaml:"template_file"` - Output string `json:"output" yaml:"output"` - NameSpace string `json:"name_space" yaml:"name_space"` - ProcessTemplate bool `json:"process_template" yaml:"process_template"` - SchemaTemplate bool `json:"schema_template" yaml:"schema_template"` - DependsOn []string `json:"depends_on" yaml:"depends_on"` - InjectTag string `json:"inject_tag" yaml:"inject_tag"` - Backup bool `json:"backup" yaml:"backup"` - RegisterSingleton string `json:"register_singleton" yaml:"register_singleton"` - RegisterRoute string `json:"register_route" yaml:"register_route"` + Name string `json:"name" yaml:"name"` + Description string `json:"description" yaml:"description"` + TemplateFile string `json:"template_file" yaml:"template_file"` + Output string `json:"output" yaml:"output"` + NameSpace string `json:"name_space" yaml:"name_space"` + ProcessTemplate bool `json:"process_template" yaml:"process_template"` + SchemaTemplate bool `json:"schema_template" yaml:"schema_template"` + DependsOn []string `json:"depends_on" yaml:"depends_on"` + InjectTag string `json:"inject_tag" yaml:"inject_tag"` + Backup bool `json:"backup" yaml:"backup"` + RegisterSingleton string `json:"register_singleton" yaml:"register_singleton"` + RegisterRoute string `json:"register_route" yaml:"register_route"` + Flags []FlagSchema `json:"flags" yaml:"flags"` +} + +type FlagSchema struct { + FieldFlag bool `json:"field_flag" yaml:"field_flag"` + Name string `json:"name" yaml:"name"` + Description string `json:"description" yaml:"description"` + Params []FlagParamSchema `json:"params" yaml:"params"` + Example string `json:"example" yaml:"example"` + OptionsRequired bool `json:"options_required" yaml:"options_required"` +} + +type FlagParamSchema struct { + Name string `json:"name" yaml:"name"` + Description string `json:"description" yaml:"description"` + DataType string `json:"data_type" yaml:"data_type"` + ParamsEnums []FlagParamEnumsSchema `json:"param_enums" yaml:"param_enums"` + Options string `json:"options" yaml:"options"` +} + +type FlagParamEnumsSchema struct { + Value string `json:"value" yaml:"value"` + Description string `json:"description" yaml:"description"` +} + +// ***************************************** +// Function to build documents for templates +// ***************************************** +func (m *CodeGen) BuildTemplateDocs(template_path string, template_doc string, template_doc_menu string, output_dir string) error { + + m.LoadTemplates(template_path) + fmt.Printf("Building Template %s\n", template_doc) + + for _, t := range m.Templates { + d := &Data{Template: &t, Templates: &m.Templates} + + //***************** + //Read the template + //***************** + template, err := lib.ReadFileToString(template_doc) + if err != nil { + return err + } + + //*************************** + //Parse the template document + //*************************** + doc, err := m.parseTemplate(template, d) + if err != nil { + return err + } + + //***************** + //Save the template + //***************** + template_file := path.Base(t.TemplateFile) + //template_file = strings.ReplaceAll(template_file, ".", "_") + save_path := path.Join(output_dir, t.Name+"_"+template_file+".md") + lib.SaveStringToFile(save_path, doc) + + } + fmt.Printf("Building Template %s\n", template_doc_menu) + //*************************** + //Parse the template menu + //*************************** + d := &Data{Templates: &m.Templates} + //***************** + //Read the template + //***************** + template, err := lib.ReadFileToString(template_doc_menu) + if err != nil { + return err + } + + //*************************** + //Parse the template document + //*************************** + doc, err := m.parseTemplate(template, d) + if err != nil { + return err + } + + //***************** + //Save the template + //***************** + + save_path := path.Join(output_dir, "Templates.md") + lib.SaveStringToFile(save_path, doc) + return nil } diff --git a/docs/img/app_accelerator.png b/documents/img/app_accelerator.png similarity index 100% rename from docs/img/app_accelerator.png rename to documents/img/app_accelerator.png diff --git a/docs/img/app_accelerator_code_style.png b/documents/img/app_accelerator_code_style.png similarity index 100% rename from docs/img/app_accelerator_code_style.png rename to documents/img/app_accelerator_code_style.png diff --git a/docs/img/app_accelerator_features.png b/documents/img/app_accelerator_features.png similarity index 100% rename from docs/img/app_accelerator_features.png rename to documents/img/app_accelerator_features.png diff --git a/docs/img/app_accelerator_nav.png b/documents/img/app_accelerator_nav.png similarity index 100% rename from docs/img/app_accelerator_nav.png rename to documents/img/app_accelerator_nav.png diff --git a/docs/img/app_accelerator_net_version.png b/documents/img/app_accelerator_net_version.png similarity index 100% rename from docs/img/app_accelerator_net_version.png rename to documents/img/app_accelerator_net_version.png diff --git a/docs/img/app_accelerator_pages.png b/documents/img/app_accelerator_pages.png similarity index 100% rename from docs/img/app_accelerator_pages.png rename to documents/img/app_accelerator_pages.png diff --git a/docs/img/app_shell.png b/documents/img/app_shell.png similarity index 100% rename from docs/img/app_shell.png rename to documents/img/app_shell.png diff --git a/docs/img/configure_maui_app.png b/documents/img/configure_maui_app.png similarity index 100% rename from docs/img/configure_maui_app.png rename to documents/img/configure_maui_app.png diff --git a/docs/img/generated_code.png b/documents/img/generated_code.png similarity index 100% rename from docs/img/generated_code.png rename to documents/img/generated_code.png diff --git a/docs/img/maui_program.png b/documents/img/maui_program.png similarity index 100% rename from docs/img/maui_program.png rename to documents/img/maui_program.png diff --git a/docs/img/new_project.png b/documents/img/new_project.png similarity index 100% rename from docs/img/new_project.png rename to documents/img/new_project.png diff --git a/docs/img/project_add_person.png b/documents/img/project_add_person.png similarity index 100% rename from docs/img/project_add_person.png rename to documents/img/project_add_person.png diff --git a/docs/img/project_folder.png b/documents/img/project_folder.png similarity index 100% rename from docs/img/project_folder.png rename to documents/img/project_folder.png diff --git a/docs/img/project_list_person.png b/documents/img/project_list_person.png similarity index 100% rename from docs/img/project_list_person.png rename to documents/img/project_list_person.png diff --git a/docs/img/project_menu.png b/documents/img/project_menu.png similarity index 100% rename from docs/img/project_menu.png rename to documents/img/project_menu.png diff --git a/docs/img/solution_explorer.png b/documents/img/solution_explorer.png similarity index 100% rename from docs/img/solution_explorer.png rename to documents/img/solution_explorer.png diff --git a/docs/maui-gen.md b/documents/maui-gen.md similarity index 84% rename from docs/maui-gen.md rename to documents/maui-gen.md index 7afac87..fc66ce1 100644 --- a/docs/maui-gen.md +++ b/documents/maui-gen.md @@ -22,8 +22,9 @@ Maui-Gen is a CLI tool to help build .Net Maui data forms from a schema. * [maui-gen build](maui-gen_build.md) - This command will build the output * [maui-gen completion](maui-gen_completion.md) - Generate the autocompletion script for the specified shell * [maui-gen gen_docs](maui-gen_gen_docs.md) - This command will build the documents for the cli +* [maui-gen gen_template_docs](maui-gen_gen_template_docs.md) - This command will build the documents for the templates * [maui-gen init](maui-gen_init.md) - init systems * [maui-gen nuget](maui-gen_nuget.md) - Set setting values * [maui-gen set](maui-gen_set.md) - Set setting values -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_about.md b/documents/maui-gen_about.md similarity index 86% rename from docs/maui-gen_about.md rename to documents/maui-gen_about.md index 30c25e6..3acca85 100644 --- a/docs/maui-gen_about.md +++ b/documents/maui-gen_about.md @@ -20,4 +20,4 @@ maui-gen about [flags] * [maui-gen](maui-gen.md) - Maui-Gen is a CLI tool to help build .Net Maui data forms from a schema -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_build.md b/documents/maui-gen_build.md similarity index 90% rename from docs/maui-gen_build.md rename to documents/maui-gen_build.md index 5e70afd..dfd0628 100644 --- a/docs/maui-gen_build.md +++ b/documents/maui-gen_build.md @@ -24,4 +24,4 @@ maui-gen build [flags] * [maui-gen](maui-gen.md) - Maui-Gen is a CLI tool to help build .Net Maui data forms from a schema -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_completion.md b/documents/maui-gen_completion.md similarity index 94% rename from docs/maui-gen_completion.md rename to documents/maui-gen_completion.md index f8660ea..6a87f5e 100644 --- a/docs/maui-gen_completion.md +++ b/documents/maui-gen_completion.md @@ -22,4 +22,4 @@ See each sub-command's help for details on how to use the generated script. * [maui-gen completion powershell](maui-gen_completion_powershell.md) - Generate the autocompletion script for powershell * [maui-gen completion zsh](maui-gen_completion_zsh.md) - Generate the autocompletion script for zsh -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_completion_bash.md b/documents/maui-gen_completion_bash.md similarity index 94% rename from docs/maui-gen_completion_bash.md rename to documents/maui-gen_completion_bash.md index de325fa..af43b6c 100644 --- a/docs/maui-gen_completion_bash.md +++ b/documents/maui-gen_completion_bash.md @@ -41,4 +41,4 @@ maui-gen completion bash * [maui-gen completion](maui-gen_completion.md) - Generate the autocompletion script for the specified shell -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_completion_fish.md b/documents/maui-gen_completion_fish.md similarity index 93% rename from docs/maui-gen_completion_fish.md rename to documents/maui-gen_completion_fish.md index 37ac612..489c18c 100644 --- a/docs/maui-gen_completion_fish.md +++ b/documents/maui-gen_completion_fish.md @@ -32,4 +32,4 @@ maui-gen completion fish [flags] * [maui-gen completion](maui-gen_completion.md) - Generate the autocompletion script for the specified shell -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_completion_powershell.md b/documents/maui-gen_completion_powershell.md similarity index 92% rename from docs/maui-gen_completion_powershell.md rename to documents/maui-gen_completion_powershell.md index 2faf437..2914470 100644 --- a/docs/maui-gen_completion_powershell.md +++ b/documents/maui-gen_completion_powershell.md @@ -29,4 +29,4 @@ maui-gen completion powershell [flags] * [maui-gen completion](maui-gen_completion.md) - Generate the autocompletion script for the specified shell -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_completion_zsh.md b/documents/maui-gen_completion_zsh.md similarity index 94% rename from docs/maui-gen_completion_zsh.md rename to documents/maui-gen_completion_zsh.md index 14ea7c3..69e0e7f 100644 --- a/docs/maui-gen_completion_zsh.md +++ b/documents/maui-gen_completion_zsh.md @@ -43,4 +43,4 @@ maui-gen completion zsh [flags] * [maui-gen completion](maui-gen_completion.md) - Generate the autocompletion script for the specified shell -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_gen_docs.md b/documents/maui-gen_gen_docs.md similarity index 88% rename from docs/maui-gen_gen_docs.md rename to documents/maui-gen_gen_docs.md index 29e2147..1915fdc 100644 --- a/docs/maui-gen_gen_docs.md +++ b/documents/maui-gen_gen_docs.md @@ -26,4 +26,4 @@ maui-gen gen_docs [flags] * [maui-gen](maui-gen.md) - Maui-Gen is a CLI tool to help build .Net Maui data forms from a schema -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/documents/maui-gen_gen_template_docs.md b/documents/maui-gen_gen_template_docs.md new file mode 100644 index 0000000..32e90cb --- /dev/null +++ b/documents/maui-gen_gen_template_docs.md @@ -0,0 +1,30 @@ +## maui-gen gen_template_docs + +This command will build the documents for the templates + +### Synopsis + + +Description: +This command will build the documents for the templates + +Example Command: +- maui-gen gen_template_docs + + +``` +maui-gen gen_template_docs [flags] +``` + +### Options + +``` + -h, --help help for gen_template_docs + -t, --templates string template path +``` + +### SEE ALSO + +* [maui-gen](maui-gen.md) - Maui-Gen is a CLI tool to help build .Net Maui data forms from a schema + +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_init.md b/documents/maui-gen_init.md similarity index 93% rename from docs/maui-gen_init.md rename to documents/maui-gen_init.md index 4abdc27..02409c9 100644 --- a/docs/maui-gen_init.md +++ b/documents/maui-gen_init.md @@ -19,4 +19,4 @@ init systems * [maui-gen init examples](maui-gen_init_examples.md) - This command will make a copy of the templates to the home directory and use them as source templates * [maui-gen init templates](maui-gen_init_templates.md) - This command will make a copy of the templates to the home directory and use them as source templates -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_init_all.md b/documents/maui-gen_init_all.md similarity index 88% rename from docs/maui-gen_init_all.md rename to documents/maui-gen_init_all.md index e216577..f846c87 100644 --- a/docs/maui-gen_init_all.md +++ b/documents/maui-gen_init_all.md @@ -20,4 +20,4 @@ maui-gen init all [flags] * [maui-gen init](maui-gen_init.md) - init systems -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_init_examples.md b/documents/maui-gen_init_examples.md similarity index 88% rename from docs/maui-gen_init_examples.md rename to documents/maui-gen_init_examples.md index 4477dd2..408ecc5 100644 --- a/docs/maui-gen_init_examples.md +++ b/documents/maui-gen_init_examples.md @@ -20,4 +20,4 @@ maui-gen init examples [flags] * [maui-gen init](maui-gen_init.md) - init systems -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_init_templates.md b/documents/maui-gen_init_templates.md similarity index 88% rename from docs/maui-gen_init_templates.md rename to documents/maui-gen_init_templates.md index 93c170d..00aa5d4 100644 --- a/docs/maui-gen_init_templates.md +++ b/documents/maui-gen_init_templates.md @@ -20,4 +20,4 @@ maui-gen init templates [flags] * [maui-gen init](maui-gen_init.md) - init systems -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_nuget.md b/documents/maui-gen_nuget.md similarity index 86% rename from docs/maui-gen_nuget.md rename to documents/maui-gen_nuget.md index 92af1f4..c6714ea 100644 --- a/docs/maui-gen_nuget.md +++ b/documents/maui-gen_nuget.md @@ -17,4 +17,4 @@ Set setting values * [maui-gen](maui-gen.md) - Maui-Gen is a CLI tool to help build .Net Maui data forms from a schema * [maui-gen nuget install](maui-gen_nuget_install.md) - This command will open the config -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_nuget_install.md b/documents/maui-gen_nuget_install.md similarity index 86% rename from docs/maui-gen_nuget_install.md rename to documents/maui-gen_nuget_install.md index 5246b10..f4e8cc0 100644 --- a/docs/maui-gen_nuget_install.md +++ b/documents/maui-gen_nuget_install.md @@ -21,4 +21,4 @@ maui-gen nuget install [flags] * [maui-gen nuget](maui-gen_nuget.md) - Set setting values -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_set.md b/documents/maui-gen_set.md similarity index 92% rename from docs/maui-gen_set.md rename to documents/maui-gen_set.md index 3630c86..658f1de 100644 --- a/docs/maui-gen_set.md +++ b/documents/maui-gen_set.md @@ -20,4 +20,4 @@ Set setting values * [maui-gen set schema](maui-gen_set_schema.md) - This command will set the default schema file * [maui-gen set template](maui-gen_set_template.md) - This command will set the default template path -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_set_edit.md b/documents/maui-gen_set_edit.md similarity index 83% rename from docs/maui-gen_set_edit.md rename to documents/maui-gen_set_edit.md index 86ae9b9..ad865c1 100644 --- a/docs/maui-gen_set_edit.md +++ b/documents/maui-gen_set_edit.md @@ -20,4 +20,4 @@ maui-gen set edit [flags] * [maui-gen set](maui-gen_set.md) - Set setting values -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_set_output.md b/documents/maui-gen_set_output.md similarity index 85% rename from docs/maui-gen_set_output.md rename to documents/maui-gen_set_output.md index 2c9e83b..223b3de 100644 --- a/docs/maui-gen_set_output.md +++ b/documents/maui-gen_set_output.md @@ -20,4 +20,4 @@ maui-gen set output [path] [flags] * [maui-gen set](maui-gen_set.md) - Set setting values -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_set_schema.md b/documents/maui-gen_set_schema.md similarity index 85% rename from docs/maui-gen_set_schema.md rename to documents/maui-gen_set_schema.md index 910f361..b19ac4f 100644 --- a/docs/maui-gen_set_schema.md +++ b/documents/maui-gen_set_schema.md @@ -20,4 +20,4 @@ maui-gen set schema [file] [flags] * [maui-gen set](maui-gen_set.md) - Set setting values -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/docs/maui-gen_set_template.md b/documents/maui-gen_set_template.md similarity index 85% rename from docs/maui-gen_set_template.md rename to documents/maui-gen_set_template.md index bda0ccb..dd9ee3d 100644 --- a/docs/maui-gen_set_template.md +++ b/documents/maui-gen_set_template.md @@ -20,4 +20,4 @@ maui-gen set template [path] [flags] * [maui-gen set](maui-gen_set.md) - Set setting values -###### Auto generated by spf13/cobra on 25-Jul-2023 +###### Auto generated by spf13/cobra on 28-Jul-2023 diff --git a/examples/person_and_pet.yaml b/examples/person_and_pet.yaml index ced1076..d7dbd07 100644 --- a/examples/person_and_pet.yaml +++ b/examples/person_and_pet.yaml @@ -67,14 +67,14 @@ schemas: - F - name: pet - type: object + type: pet constructor: false flags: - name: "VALIDATE_Required" - name: "RELATIONSHIP:pet,Animal_details" - name: team - type: object + type: team constructor: false flags: - name: "VALIDATE_Required" diff --git a/lib/lib_helper.go b/lib/lib_helper.go index 549ace7..6319a6b 100644 --- a/lib/lib_helper.go +++ b/lib/lib_helper.go @@ -9,6 +9,13 @@ import ( "strings" ) +func NA(value string) string { + if value == "" { + return "N/A" + } + return value +} + func CheckValidUrl(host string) error { if strings.Contains(strings.ToLower(host), "http://") || strings.Contains(strings.ToLower(host), "https://") { return nil @@ -38,7 +45,7 @@ func IsNumber(s string) bool { return err == nil } -//strip the schema from url +// strip the schema from url func GetDomainOrIP(url_str string) string { u, _ := url.Parse(url_str) host, _, _ := net.SplitHostPort(u.Host) diff --git a/templates/Interfaces/IModel_Template.cs b/templates/Interfaces/IModel_Template.cs index b86011a..9aff7dc 100644 --- a/templates/Interfaces/IModel_Template.cs +++ b/templates/Interfaces/IModel_Template.cs @@ -7,8 +7,8 @@ namespace {{.FullNS}} { public interface I{{.Schema.FuncName}} { #region Fields - {{range $field := .Schema.Fields}}{{$field.Type}} {{$field.PubVarName}} { get; set; } - {{end}} + {{range $field := .Schema.Fields}}{{if $field.FlagExists `Model_Template_EXCLUDE`}}{{else}}{{$field.Type}} {{$field.PubVarName}} { get; set; } + {{end}}{{end}} #endregion Fields #region Methods diff --git a/templates/Views/EditPage_Template.xaml b/templates/Views/EditPage_Template.xaml index db6f14a..cefc1a6 100644 --- a/templates/Views/EditPage_Template.xaml +++ b/templates/Views/EditPage_Template.xaml @@ -53,82 +53,8 @@ IsVisible="{Binding {{$field.PubVarName}}_error, Converter={StaticResource GNotEmpty}}" Text="{Binding {{$field.PubVarName}}_error}" TextColor="Red" /> - {{if eq $field.Type "string"}} - {{if $field.FlagExists `EditView_PICKER`}}{{$data_type := pub_var_name ($field.GetFlagParam `EditView_PICKER` 1)}} - - - {{range $data := ($field.GetOpt `EditView_PICKER`).data}}{{$data}} - {{end}} - - {{end}}{{end}} - {{else if $field.FlagExists `EditView_EDITOR`}} - - {{else}} - - {{end}} - {{else if ($field.FlagExists `RELATIONSHIP`)}} - - - -