Skip to content

Commit

Permalink
v0.1.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mrpye committed Jul 27, 2023
1 parent 6010571 commit 69ecca0
Show file tree
Hide file tree
Showing 51 changed files with 770 additions and 194 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ answer*.yaml
# vendor/

/output
/documents

config.json
/export.zip

59 changes: 37 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
</details>

Expand All @@ -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)
</details>

Expand All @@ -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)
</details>

Expand All @@ -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)
</details>

Expand All @@ -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)
</details>

Expand All @@ -163,7 +163,7 @@ You can select Flyout or Tabs
![Navigation](docs/img/app_accelerator_nav.png)
![Navigation](documents/img/app_accelerator_nav.png)
</details>

Expand All @@ -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)
</details>

Expand All @@ -191,7 +191,7 @@ Add the following libraries:
![Features](docs/img/app_accelerator_features.png)
![Features](documents/img/app_accelerator_features.png)
</details>

Expand All @@ -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)
</details>

Expand All @@ -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
Expand Down Expand Up @@ -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<MainViewModel();** and save changes.
```c#
public static class MauiProgram {
Expand Down Expand Up @@ -303,7 +303,7 @@ In this case we are pointing it to the **DemoMauiApp** created earlier.
![MauiProgram](docs/img/project_folder.png)
![MauiProgram](documents/img/project_folder.png)
Expand Down Expand Up @@ -432,7 +432,7 @@ Now that the code has been generated your can goto you Visual studio and you wil
![Generated Code](docs/img/generated_code.png)
![Generated Code](documents/img/generated_code.png)
Expand All @@ -441,24 +441,37 @@ You can now simple run the project and you should see.
#### Main Menu
![Menu](docs/img/project_menu.png)
![Menu](documents/img/project_menu.png)
#### Edit Person Form
![Add Person](docs/img/project_add_person.png)
![Add Person](documents/img/project_add_person.png)
#### List Person Form
![Add Person](docs/img/project_list_person.png)
![Add Person](documents/img/project_list_person.png)
</details>

---

## 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
Expand All @@ -467,13 +480,13 @@ You can now simple run the project and you should see.
<summary>Example Pictures</summary
#### Main Menu
![Menu](docs/img/project_menu.png)
![Menu](documents/img/project_menu.png)
#### Edit Person Form
![Add Person](docs/img/project_add_person.png)
![Add Person](documents/img/project_add_person.png)
#### List Person Form
![Add Person](docs/img/project_list_person.png)
![Add Person](documents/img/project_list_person.png)
</details>

Expand Down Expand Up @@ -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
Expand Down
78 changes: 74 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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)
}
Expand All @@ -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",
Expand All @@ -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
},
Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 69ecca0

Please sign in to comment.