Skip to content

Commit

Permalink
minor: docs progress
Browse files Browse the repository at this point in the history
  • Loading branch information
liquidg3 committed May 20, 2020
1 parent 86a541c commit 812ea14
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 17 deletions.
Binary file added _images/template-generation.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
32 changes: 29 additions & 3 deletions autoloader/index.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Autoloader
Instantiate entire directories at once with full typing, sibling visibility, and key based access.
```bash
# Create a new autoloader based on a directory
spruce autoloader:create [name]
# Create a new autoloader based on a name, like services or adapters
spruce autoloader:create [namePlural]

Options:
-p, --pattern Any pattern you want to use for loading files
Expand All @@ -15,10 +15,36 @@ Options:

-rd, --rootDestination Where should I save the root autoloader?

# Update autoloaders based on changes (deleting or adding files)
spruce autoloader:sync

# Create new root autoloader
spruce autoloader:root

Options:
```
## Building your first autoloader
You need utilities, admit it!
```
```bash
spruce autoloader:create utilities
```
<!-- panels:start -->****
<!--div:title-panel-->
## Generated files
<!-- div:left-panel -->
After running `spruce autoloader:create` up to 4 files were created for you.
1. **Example abstract class:** `.src/{{nameCamelPlural}}/Abstract{{nameCamel}}.ts`
1. The start of an abstract class that others will extend
2. Extends `IAutoloadable`
<!-- div:right-panel -->
<!-- tabs:start -->
### ** 1. Autoloader **
aououaoe
### ** 1. Root Autoloader **
satoheusnatoheu
<!-- tabs:end -->
<!-- panels:end -->
2 changes: 1 addition & 1 deletion errors/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Now review the generated files before we jump into the definition itself.
<!-- div:left-panel -->
After running `spruce error:create` up to 4 files were created for you.

1. **Definition:** `./src/errors/{{camelName}}.definition.ts`
1. **Definition:** `./src/errors/{{nameCamel}}.definition.ts`
* Where the actual definition lives
* Extends `ISchemaDefinition`, so you already know how it works!
* Make your changes and run `spruce error:sync` to update the interface files
Expand Down
59 changes: 59 additions & 0 deletions schemas/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,65 @@ spruce schema:create "Soccer ball"
spruce schema:create "Vendor"
```

<!-- panels:start -->
<!--div:title-panel-->
## Generated files
<!-- div:left-panel -->
After running `spruce schema:create` up to 2 files were created for you.
****
1. **Definition:** `./src/schemas/{{nameCamel}}.definitions.ts`
* Where your new definition lives
* After making changes, run `spruce schema:sync` to update interface files
2. **Types:** `#spruce/schemas/schemas.types.ts`
* Where all interfaces live
* Accessible through `SpruceSchemas`
* `const adidas: SpruceSchemas.Local.IVendor = { name: 'adidas' }`
<!-- div:right-panel -->
<!-- tabs:start -->
#### ** 1. Definition **
```ts
// ./src/schemas/vendor.definition.ts

import Schema, { FieldType, buildSchemaDefinition } from '@sprucelabs/schema'

const vendorDefinition = buildSchemaDefinition({
id: 'vendor',
name: 'Vendor',
description: 'A vendor is a company that makes balls',
fields: {
id: {
type: FieldType.Id,
label: 'Id',
isRequired: true,
},
name: {
type: FieldType.Text,
label: 'Name',
hint: 'How they are incorporated',
}
}
})

export default vendorDefinition
```
#### ** 2. Types **
Has both Core and Local types and definitions
```ts
// #spruce/schemas/schemas.types.ts

export namespace SpruceSchemas.Local {
/** Profile images at various helpful sizes and resolutions. */
export interface IProfileImage {
/** Id. */
id: string
/** Name. How they are incorporated */
name?: string | undefined | null
}
}
```
<!-- tabs:end -->
<!-- panels:end -->

## Updating definitions

We'll start by defining our Vendor schema since it's required for the ball schemas.
Expand Down
16 changes: 3 additions & 13 deletions standards/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,9 @@ We use singletons for various things like logging and Mercury.
1. `const users = this.store.user.users(...)`
2. `const users = this.store.user.usersById()`

## Generators

1. Code that writes to “generated” files
2. Templates must be hbs
3. Generators live in CLI as the source of the template (.hbs)
4. Example, SchemaGenerator is in @sprucelabs/schemas
5. Generators in a folder called @sprucelabs/spruce-cli /generators
6. Class name ends in Generator
7. Each method starts with generator
8. Generators must return a string (not write a file)
9. Handling handlebar helpers
1. helpers are "addons"
10. TODO: define event contracts for mercury for pulling types
## Generating templates

![Generating templates](../_images/template-generation.jpeg?raw=true "Generating templates")

## **Addons**

Expand Down

0 comments on commit 812ea14

Please sign in to comment.