Skip to content

Commit

Permalink
Replace old doc generation process with new tfplugindocs tool (#356)
Browse files Browse the repository at this point in the history
* rename directories

* move index page (it doesn't appear to be dynamially generated)

* remove old ruby file no longer needed

* rename obsolete file as code implementation requires it to continue to exist

* todo

* update README

* rename and regenerate all pages

* remove no-op file and print statement

* updated Markdown generated from tfplugindocs

* tweak README to include online preview tool

* clarifying notes

* rename docs_src to templates and regenerate content

* update README

* update Makefile

* update README with new Makefile targets

* use SchemaMarkdown to render existing template content

* remove obsolete yaml frontmatter

* steps to get this thing working

* remove generated docs

* run tfplugindocs generate

* final step

* update README and Makefile

* remove print of temp directory

* docs

* rename script to generate docs

* remove CI website check

* sometimes the github markdown renderer gets confused and doesn't render headers 🤦‍♂️

* update renamed makefile target

* make README code use consistent

* add link to terraform documentation

* fix typo in Makefile PHONY definition

* add missing index page

* fix bug in docs generation where index.md was omitted

* Fix bug where index.md was missing

* remove attr ref from ip ranges

* remove arg ref from acl entries

* add missing descriptions related to service resources

* multiple documentation updates/fixes

* replace docs link with dev link

* replace function with Getwd()

* revert frontmatter deletions

* regenerate docs with frontmatter put back

* delete no longer used templates as generated by schema data
  • Loading branch information
Integralist committed Jan 29, 2021
1 parent 44c9f1d commit 98bbed6
Show file tree
Hide file tree
Showing 137 changed files with 2,832 additions and 3,594 deletions.
29 changes: 0 additions & 29 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,32 +43,3 @@ jobs:
${{ runner.os }}-go-mod-
- name: Test
run: make test
website:
runs-on: ubuntu-latest
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: 1.14.x
- name: Set Go variables for backwards compatibility
run: |
echo "GOPATH=$GITHUB_WORKSPACE/go" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
with:
path: go/src/github.com/${{ github.repository }}
- name: Checkout code
uses: actions/checkout@v2
with:
repository: 'hashicorp/terraform-website'
path: go/src/github.com/hashicorp/terraform-website
- name: Run website-test
run: |
cd $GOPATH/src/github.com/${{ github.repository }}
ln -sf ../../../../ext/providers/fastly/website/docs $GOPATH/src/github.com/hashicorp/terraform-website/content/source/docs/providers/fastly
ln -sf ../../../../ext/providers/fastly/website/fastly.erb $GOPATH/src/github.com/hashicorp/terraform-website/content/source/layouts/fastly.erb
make website-test
- name: Check diff
run: |
cd $GOPATH/src/github.com/${{ github.repository }}
git diff-files --ignore-all-space --name-only --exit-code
21 changes: 5 additions & 16 deletions GNUmakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,21 +52,10 @@ test-compile:
fi
go test -c $(TEST) $(TESTARGS)

website:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
go run "scripts/website/parse-templates.go"
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)
generate-docs:
go run scripts/generate-docs.go

website-test:
ifeq (,$(wildcard $(GOPATH)/src/$(WEBSITE_REPO)))
echo "$(WEBSITE_REPO) not found in your GOPATH (necessary for layouts and assets), get-ting..."
git clone https://$(WEBSITE_REPO) $(GOPATH)/src/$(WEBSITE_REPO)
endif
go run "scripts/website/parse-templates.go"
@$(MAKE) -C $(GOPATH)/src/$(WEBSITE_REPO) website-provider-test PROVIDER_PATH=$(shell pwd) PROVIDER_NAME=$(PKG_NAME)

.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile website website-test
validate-docs:
tfplugindocs validate

.PHONY: build test testacc vet fmt fmtcheck errcheck test-compile validate-docs generate-docs
45 changes: 21 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
Terraform Provider
==================
# Fastly Terraform Provider

- Website: https://www.terraform.io
- Documentation: https://registry.terraform.io/providers/fastly/fastly/latest/docs
- Mailing list: http://groups.google.com/group/terraform-tool
- [![Gitter chat](https://badges.gitter.im/hashicorp-terraform/Lobby.png)](https://gitter.im/hashicorp-terraform/Lobby)
- Mailing list: [Google Groups](http://groups.google.com/group/terraform-tool)

<img src="https://cdn.rawgit.com/hashicorp/terraform-website/master/content/source/assets/images/logo-hashicorp.svg" width="600px">

Requirements
------------

- [Terraform](https://www.terraform.io/downloads.html) 0.10.x
- [Go](https://golang.org/doc/install) 1.14 (to build the provider plugin)

Building The Provider
---------------------
## Building The Provider

Clone repository to: `$GOPATH/src/github.com/fastly/terraform-provider-fastly`

Expand All @@ -30,12 +27,7 @@ $ cd $GOPATH/src/github.com/fastly/terraform-provider-fastly
$ make build
```

Using the provider
----------------------
## Fill in for each provider

Developing the Provider
---------------------------
## Developing the Provider

If you wish to work on the provider, you'll first need [Go](http://www.golang.org) installed on your machine (version 1.14+ is *required*).

Expand Down Expand Up @@ -83,21 +75,26 @@ In order to run the tests with extra debugging context, prefix the `make` comman
$ TF_LOG=trace make testacc
```

Building The Documentation
--------------------------
## Building The Documentation

The documentation is built from components (go templates) stored in the `website_src` folder.
Building the documentation copies the full markdown into the `website` folder, ready for deployment to Hashicorp.
The documentation is built from components (go templates) stored in the `templates` folder.
Building the documentation copies the full markdown into the `docs` folder, ready for deployment to Hashicorp.

With the repository cloned to: `$GOPATH/src/github.com/fastly/terraform-provider-fastly`:
> NOTE: you'll need the [`tfplugindocs`](https://github.com/hashicorp/terraform-plugin-docs) tool for generating the Markdown to be deployed to Hashicorp. For more information on generating documentation, refer to https://www.terraform.io/docs/registry/providers/docs.html
* To build the documentation:
`go run scripts/website/parse-templates.go `
* To validate the `/template` directory structure:
```
make validate-docs
```

* To build the `/docs` documentation Markdown files:
```
make generate-docs
```

* To build and preview the documentation online:
`make website`
* To view the documentation:
Paste `/docs` Markdown file content into https://registry.terraform.io/tools/doc-preview

Contributing
--------------------------
## Contributing

Refer to [CONTRIBUTING.md](./CONTRIBUTING.md)
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,21 @@ resource "aws_security_group" "from_fastly" {
from_port = "443"
to_port = "443"
protocol = "tcp"
cidr_blocks = data.fastly_ip_ranges.fastly.cidr_blocks
ipv6_cidr_blocks = data.fastly_ip_ranges.fastly.ipv6_cidr_blocks
cidr_blocks = ["${data.fastly_ip_ranges.fastly.cidr_blocks}"]
ipv6_cidr_blocks = ["${data.fastly_ip_ranges.fastly.ipv6_cidr_blocks}"]
}
}
```

## Attributes Reference
[1]: https://docs.fastly.com/guides/securing-communications/accessing-fastlys-ip-ranges
<!-- schema generated by tfplugindocs -->
## Schema

* `cidr_blocks` - The lexically ordered list of ipv4 CIDR blocks.
* `ipv6_cidr_blocks` - The lexically ordered list of ipv6 CIDR blocks.
### Optional

[1]: https://docs.fastly.com/guides/securing-communications/accessing-fastlys-ip-ranges
- **id** (String) The ID of this resource.

### Read-only

- **cidr_blocks** (List of String) The lexically ordered list of ipv4 CIDR blocks.
- **ipv6_cidr_blocks** (List of String) The lexically ordered list of ipv6 CIDR blocks.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description: |-
Get information on Fastly WAF rules.
---

-> **Note:** This data source is only available from x.x.x of the Fastly terraform provider.
-> **Note:** This data source is only available from 0.20.0 of the Fastly terraform provider.

# fastly_waf_rules

Expand Down Expand Up @@ -125,6 +125,8 @@ resource "fastly_service_waf_configuration" "waf" {
}
```



## Argument Reference

~> **Warning:** The data source's filters are applied using an **AND** boolean operator, so depending on the combination of filters, they may become mutually exclusive.
Expand All @@ -145,4 +147,27 @@ The `rules` block supports:
* `latest_revision_number` - The rule's latest revision.
* `type` - The rule's type.

[1]: https://docs.fastly.com/api/ngwaf#ngwaf_rules
[1]: https://developer.fastly.com/reference/api/waf/rules/

<!-- schema generated by tfplugindocs -->
## Schema

### Optional

- **exclude_modsec_rule_ids** (List of Number) A list of modsecurity rules IDs to be excluded from the data set.
- **id** (String) The ID of this resource.
- **publishers** (List of String) A list of publishers to be used as filters for the data set.
- **tags** (List of String) A list of tags to be used as filters for the data set.

### Read-only

- **rules** (List of Object) The list of rules that results from any given combination of filters. (see [below for nested schema](#nestedatt--rules))

<a id="nestedatt--rules"></a>
### Nested Schema for `rules`

Read-only:

- **latest_revision_number** (Number)
- **modsec_rule_id** (Number)
- **type** (String)
6 changes: 2 additions & 4 deletions website/docs/index.html.markdown → docs/index.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
---
layout: "fastly"
page_title: "Provider: Fastly"
sidebar_current: "docs-fastly-index"
page_title: "fastly Provider"
subcategory: ""
description: |-
Fastly
---

# Fastly Provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ resource "fastly_service_acl_entries_v1" "entries" {
}
```

## Example Usage (Terraform >= 0.12.0 && < 0.12.6)
## Example Usage (Terraform >= 0.12.0 && &lt; 0.12.6)

`for_each` attributes were not available in Terraform before 0.12.6, however, users can still use `for` expressions to achieve
similar behaviour as seen in the example below.
Expand Down Expand Up @@ -199,24 +199,6 @@ resource "fastly_service_acl_entries_v1" "entries" {
}
```


## Argument Reference

The following arguments are supported:

* `service_id` - (Required) The ID of the Service that the ACL belongs to
* `acl_id` - (Required) The ID of the ACL that the items belong to
* `entry` - (Optional) A Set ACL entries that are applied to the service. Defined below

The `entry` block supports:

* `ip` - (Required, string) An IP address that is the focus for the ACL
* `subnet` - (Optional, string) An optional subnet mask applied to the IP address
* `negated` - (Optional, boolean) A boolean that will negate the match if true
* `comment` - (Optional, string) A personal freeform descriptive note



## Attributes Reference

* [fastly-acl](https://developer.fastly.com/reference/api/acls/acl/)
Expand All @@ -237,3 +219,33 @@ The following is an example of the Terraform state command to remove the resourc
```
$ terraform state rm fastly_service_acl_entries_v1.entries
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- **acl_id** (String) The ID of the ACL that the items belong to
- **service_id** (String) The ID of the Service that the ACL belongs to

### Optional

- **entry** (Block Set, Max: 10000) (see [below for nested schema](#nestedblock--entry))
- **id** (String) The ID of this resource.

<a id="nestedblock--entry"></a>
### Nested Schema for `entry`

Required:

- **ip** (String) An IP address that is the focus for the ACL

Optional:

- **comment** (String) A personal freeform descriptive note
- **negated** (Boolean) A boolean that will negate the match if true
- **subnet** (String) An optional subnet mask applied to the IP address

Read-only:

- **id** (String) The ID of this resource.
Loading

0 comments on commit 98bbed6

Please sign in to comment.