Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 3d4a15a

Browse files
authoredDec 23, 2020
Docs update (#148)
* Update docs * Update docs
1 parent 897a2dd commit 3d4a15a

File tree

6 files changed

+142
-15
lines changed

6 files changed

+142
-15
lines changed
 

‎docs/README.md

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,26 @@
11
# Functions Framework for Dart
22

3+
These docs will help you get started with the [Functions Framework for Dart],
4+
an open source **FaaS** (Function as a Service) framework that lets you write
5+
and deploy lightweight, event-driven functions.
6+
37
## Contents
48

5-
[1 Introduction](01-introduction.md)
6-
[2 Quickstart: Dart](quickstarts/01-quickstart-dart.md)
7-
[3 Quickstart: Docker](quickstarts/02-quickstart-docker.md)
8-
[4 Quickstart: Cloud Run](quickstarts/03-quickstart-cloudrun.md)
9+
[Introduction](01-introduction.md)
10+
11+
### Setting up
12+
13+
[Install dartfn](quickstarts/00-install-dartfn.md)
14+
15+
### Quickstarts
16+
17+
[Quickstart: Dart](quickstarts/01-quickstart-dart.md)
18+
[Quickstart: Docker](quickstarts/02-quickstart-docker.md)
19+
[Quickstart: Cloud Run](quickstarts/03-quickstart-cloudrun.md)
920

1021
---
1122
[[next]](01-introduction.md)
23+
24+
<!-- Reference links -->
25+
[functions framework for dart]:
26+
https://github.com/GoogleCloudPlatform/functions-framework-dart

‎docs/quickstarts/00-install-dartfn.md

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
# Installing and using dartfn
2+
3+
`dartfn` is a command-line (CLI) tool for working with Dart Functions Framework
4+
projects. In this early version of the tool, you can use it to generate sample
5+
projects from templates. Currently there are three templates:
6+
7+
- helloworld - a basic HTTP handler function
8+
- json - a simple function handler that accepts and sends JSON
9+
- cloudevent - a simple cloudevent function handler
10+
11+
## Prerequisites
12+
13+
- [Dart SDK] v2.10+
14+
15+
## Install dartfn
16+
17+
To install `dartfn` on your machine, run the following command:
18+
19+
```shell
20+
dart pub global activate dartfn
21+
```
22+
23+
Output
24+
25+
```text
26+
dart pub global activate functions_framework_tool
27+
Resolving dependencies... (1.2s)
28+
...
29+
Precompiling executables... (1.1s)
30+
Precompiled functions_framework_tool:dartfn.
31+
Installed executable dartfn.
32+
Activated functions_framework_tool 0.3.0.
33+
```
34+
35+
## Using dartfn
36+
37+
### List available generators
38+
39+
```shell
40+
dartfn generate --list
41+
```
42+
43+
Output
44+
45+
```text
46+
Available generators:
47+
cloudevent - A sample Functions Framework project for handling a cloudevent.
48+
helloworld - A sample "Hello, World!" Functions Framework project.
49+
json - A sample Functions Framework project for handling JSON.
50+
```
51+
52+
### Generate a project
53+
54+
Generate a `helloworld` project, for example:
55+
56+
```shell
57+
mkdir helloworld
58+
cd helloworld
59+
dartfn generate helloworld
60+
```
61+
62+
Output
63+
64+
```text
65+
project: demo
66+
Creating helloworld application `ex`:
67+
demo/.gitignore
68+
demo/Dockerfile
69+
demo/README.md
70+
demo/analysis_options.yaml
71+
demo/bin/server.dart
72+
demo/lib/functions.dart
73+
demo/pubspec.yaml
74+
demo/test/function_test.dart
75+
8 files written.
76+
77+
--> to provision required packages, run 'pub get'
78+
```
79+
80+
### Get the new project package dependencies
81+
82+
```shell
83+
dart pub get
84+
```
85+
86+
Output
87+
88+
```text
89+
Resolving dependencies... (2.1s)
90+
...
91+
Changed 74 dependencies!
92+
```
93+
94+
---
95+
[[toc]](../README.md)
96+
[[back]](../01-introduction.md)
97+
[[next]](01-quickstart-dart.md)
98+
99+
<!-- reference links -->
100+
[Dart SDK]: https://dart.dev/get-dart

‎docs/quickstarts/01-quickstart-dart.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@ normal developer workflow.
1010

1111
## Get a copy of the `hello` example
1212

13-
Clone this repo or download a [zip] archive and extract the contents. Change
14-
directory to `examples/hello`.
13+
You can either
14+
15+
* Run `dartfn` to create a new project using the `helloworld` generator (see
16+
[Installing and using dartfn])
17+
* Clone this repo or download a [zip] archive and extract the contents
18+
* Change directory to `examples/hello`.
1519

1620
## Build the example
1721

@@ -159,12 +163,13 @@ Listening on :8080
159163

160164
---
161165
[[toc]](../README.md)
162-
[[back]](../01-introduction.md)
166+
[[back]](00-install-dartfn.md)
163167
[[next]](02-quickstart-docker.md)
164168

165169
<!-- reference links -->
166170
[curl]: https://curl.se/docs/manual.html
167171
[Dart SDK]: https://dart.dev/get-dart
172+
[Installing and using dartfn]: 00-install-dartfn.md
168173
[Request]: https://pub.dev/documentation/shelf/latest/shelf/Request-class.html
169174
[Response]: https://pub.dev/documentation/shelf/latest/shelf/Response-class.html
170175
[Shelf]: https://pub.dev/packages/shelf

‎docs/quickstarts/02-quickstart-docker.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,12 @@ environment.
1313

1414
## Get a copy of the `hello` example
1515

16-
Clone this repo or download a [zip] archive and extract the contents. Change
17-
directory to `examples/hello`.
16+
You can either
17+
18+
* Run `dartfn` to create a new project using the `helloworld` generator (see
19+
[Installing and using dartfn])
20+
* Clone this repo or download a [zip] archive and extract the contents
21+
* Change directory to `examples/hello`.
1822

1923
## Build a Docker image
2024

@@ -203,4 +207,5 @@ docker image rm hellofunc # remove the image
203207

204208
<!-- reference links -->
205209
[docker]: https://docs.docker.com/get-docker/
210+
[Installing and using dartfn]: 00-install-dartfn.md
206211
[zip]: https://github.com/GoogleCloudPlatform/functions-framework-dart/archive/main.zip

‎docs/quickstarts/03-quickstart-cloudrun.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,10 @@ Updated property [core/project].
4646

4747
## Get a copy of the `hello` example
4848

49-
Clone this repo or download a [zip] archive and extract the contents. Change
50-
directory to `examples/hello`.
49+
* Run `dartfn` to create a new project using the `helloworld` generator (see
50+
[Installing and using dartfn])
51+
* Clone this repo or download a [zip] archive and extract the contents
52+
* Change directory to `examples/hello`.
5153

5254
## Build and deploy with a single command
5355

@@ -164,6 +166,7 @@ the [Manage resources] page.
164166
[gcloud]: https://cloud.google.com/sdk/docs/install
165167
[Google Cloud]: https://cloud.google.com/gcp
166168
[incur charges]: https://cloud.google.com/container-registry/pricing
169+
[Installing and using dartfn]: 00-install-dartfn.md
167170
[Manage resources]: https://console.cloud.google.com/iam-admin/projects
168171
[project selector]: https://console.cloud.google.com/projectselector2/home/dashboard
169172
[quickstart]: https://cloud.google.com/sdk/docs/quickstart

‎functions_framework_tool/README.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ In this early iteration, a CLI tool (`dartfn`) is provided with a `generate`
77
command for scaffolding new projects into an empty directory. Three initial
88
generator templates are available:
99

10-
* helloworld - a basic HTTP handler function
11-
* json - a simple function handler that accepts and sends JSON
12-
* cloudevent - a simple cloudevent function handler
10+
- helloworld - a basic HTTP handler function
11+
- json - a simple function handler that accepts and sends JSON
12+
- cloudevent - a simple cloudevent function handler
1313

1414
To install the `dartfn` tool on your machine, run the following command:
1515

@@ -123,4 +123,3 @@ Output
123123
```text
124124
0.3.1
125125
```
126-

0 commit comments

Comments
 (0)