Skip to content

Commit

Permalink
docs: CleanUp and add examples (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
amanv8060 authored Jan 22, 2023
1 parent 8460214 commit 866b060
Show file tree
Hide file tree
Showing 17 changed files with 149 additions and 40 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,3 @@ aquila

# .idea files
.idea


aquila.yaml
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ Manage Docs Seamlessly. Aquila Helps you to manage testable code snippets in you

## Usage

See Usage Instructions.
See Usage Instructions [here](how_to_use.md), and also see the [example](example/).

Building from Source :
### Building from Source :

```bash
git clone [email protected]:amanv8060/aquila.git
Expand Down
12 changes: 6 additions & 6 deletions cmd/generate.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import (
// generateCmd represents the generate command
var generateCmd = &cobra.Command{
Use: "generate",
Short: "A brief description of your command",
Long: `A longer description that spans multiple lines and likely contains examples
and usage of using your command. For example:
Short: "Generate code regions from your codebase.",
Long: `Generate command generates code regions from your codebase.
Cobra is a CLI library for Go that empowers applications.
This application is a tool to generate the needed files
to quickly create a Cobra application.`,
It will generate code regions from a given codebase and store them in a directory called code_regions within a path
specified by the user through config file. The code regions are stored in a JSON file with the name of the file as
the key and the value being an array of strings containing the code region.
`,
Run: func(cmd *cobra.Command, args []string) {
codePath := viper.GetString("codePath")
// recursively get all files path in the codePaths
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var cfgFile string
// rootCmd represents the base command when called without any subcommands
var rootCmd = &cobra.Command{
Use: "aquila",
Short: "A brief description of your application",
Short: "Aquila is a tool to manage your docs seamlessly.",
Long: rootCommandHeader,
}

Expand Down
16 changes: 14 additions & 2 deletions cmd/updatemd.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
/*
Copyright © 2022 Aman Verma. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
*/

package cmd

import (
"aquila/utils"
"github.com/spf13/cobra"
)

// generateCmd represents the generate command
// updateMdCmd represents the generate command
var updateMdCmd = &cobra.Command{
Use: "update-md",
Short: "Update Annotated Regions in your markdown with code regions",
Long: `Updates the annotated regions in your markdown with the code regions.`,
Long: `Updates the annotated regions in your markdown with the code regions.
It will update the annotated regions in your markdown with the code regions from the code_regions directory.
It works on insert-or-replace basis. If the annotated region is not present in the markdown, it will be inserted.
If the annotated region has a code region present in the markdown, it will be replaced with the newly generated code
region.
`,
Run: func(cmd *cobra.Command, args []string) {
utils.UpdateRegions()
},
Expand Down
1 change: 0 additions & 1 deletion code_regions/main.go.json

This file was deleted.

19 changes: 0 additions & 19 deletions docs/test.md

This file was deleted.

2 changes: 2 additions & 0 deletions example/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Ignore Code Regions if you don't want to be source controlled.
code_regions/
2 changes: 2 additions & 0 deletions example/aquila.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
codePath: "."
docsPath: "./docs"
21 changes: 21 additions & 0 deletions example/docs/Getting_Started(original).md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
## Getting Started

This is a simple example of how to use the `example` package.

### Installation

Clone the repo and cd into the directory:

git clone
cd example

## Example Functions :

### How to say Hi

`<?code-region "main.js" region="sayHi"?>`

### How to add in js

`<?code-region "main.js" region="addition"?>`

36 changes: 36 additions & 0 deletions example/docs/Getting_Started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Getting Started

This is a simple example of how to use the `example` package.

### Installation

Clone the repo and cd into the directory:

git clone
cd example

## Example Functions :

### How to say Hi

<?code-region "main.js" region="sayHi"?>
```js

// Function to say hi.
function sayHi() {
console.log("Hi!");
}
...
```

### How to add in js

<?code-region "main.js" region="addition"?>
```js

function addition(a, b) {
return a + b;
}
...
```

18 changes: 18 additions & 0 deletions example/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// #aqstart sayHi

// Function to say hi.
function sayHi() {
console.log("Hi!");
}

// #aqend sayHi


// #aqstart addition

function addition(a, b) {
return a + b;
}

// #aqend addition

11 changes: 11 additions & 0 deletions example/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "example_code_repo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC"
}
24 changes: 24 additions & 0 deletions how_to_use.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
## How to Use

Using aquila is a 3-step process:

### Setup Config Files

- Create `aquila.yaml` config file.
- Specify the `codePath` & `docsPath` directory in the config file.

### Setting Up

- Annotate all the code regions that might be used within the docs using a comment `#aqstart <region-name>`
and closing it with `#aqend <region-name>`.
- Wherever you want to use the code region in the docs, use the following
syntax: `<?code-region <file-name> region="<region-name>"?>`.

### Using

- Generate the docs using `aquila generate` command.
- The generated docs will be present in the `./code_regions` directory.
- Run `aquila update-md` to update the docs with the generated code regions.

Example can be found [here](example/).

6 changes: 0 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,8 @@ license that can be found in the LICENSE file.

package main

// #aqstart imports
import "aquila/cmd"

// #aqend imports

// #aqstart main
func main() {
cmd.Execute()
}

// #aqend main
6 changes: 6 additions & 0 deletions models/codeRegion.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright © 2022 Aman Verma. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
*/

package models

import "regexp"
Expand Down
6 changes: 6 additions & 0 deletions utils/updateRegions.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
Copyright © 2022 Aman Verma. All rights reserved.
Use of this source code is governed by a BSD-style
license that can be found in the LICENSE file.
*/

package utils

import (
Expand Down

0 comments on commit 866b060

Please sign in to comment.