swissshepherd

Doc styles: reference and tfplugindocs

Issues #116 and #117. swissshepherd was written for one page shape, the AWS provider’s, and providers whose docs tfplugindocs generates failed on every page even when the docs were complete. This doc defines the two page shapes swissshepherd reads, how each maps onto its rules, and the finding for a doc whose reference section is missing.

1. The two styles

Set doc_style at the top of the config. It applies to every type.

  reference (default) tfplugindocs
Providers AWS, Google, Azure, most hand-written docs Providers that run tfplugindocs generate with its default templates (random, tls, cloudinit, datadog, cloudflare)
Title # Resource: name (prefix from title_prefix / allow_prefixes) # name (Resource), # name (Data Source), # name (Ephemeral Resource), # name (List Resource), # name (Action), # function: name (title_format)
Reference sections ## Argument Reference and ## Attribute Reference One ## Schema (## Arguments for functions)
A field’s label Inline: * `name` - (Required) ... The group it’s listed under: ### Required, ### Optional, ### Read-Only at the root, Required: / Optional: / Read-Only: under each nested heading
A field bullet * `name` - (Optional) Description - `name` (String, Deprecated) Description; older releases write - **name** (String) ...
Nested heading Any block_heading_styles template ### Nested Schema for `path` under an <a id="nestedblock--path"> anchor
Timeouts ## Timeouts section A nested timeouts block in ## Schema
Import example ```terraform import { block first, then ```console Optional import { blocks, then ```shell

Why a config setting and not detection per doc: detection changes which rules apply on a guess, so a half-converted doc would be judged by whichever style it resembles. Providers mix styles by mistake (kubernetes has 7 Argument Reference pages among 116 Schema pages; tfe keeps some Schema pages under website/docs), and those pages should be reported, not silently read another way. file_match’s mixed_layout made the same choice.

Why not a preset of existing options: the tfplugindocs field label lives in a group heading, not on the bullet, and its bullet has no ` - ` separator. No combination of heading templates and section names reads that. Pointing arguments_heading at Schema in the reference style makes things worse: ### Required becomes a phantom block and every nested bullet “is missing the ‘ - ‘ separator” (cloudinit: 15 errors).

2. What the tfplugindocs style changes

The style chooses defaults; every one can still be set in the config, except where noted.

What stays the same: field homes collapse to one section, but every other schema_docs invariant holds. A field listed twice, a field that doesn’t exist, a deprecated field not marked, and a nested block with missing fields are reported as in the reference style.

3. A missing reference section (#117)

Defect. With no arguments section, coverage checked no root argument: the root block is excluded from “block is not documented”, and resolving it found no section. Unless the type required the section, nothing reported it. ldap’s tfplugindocs page, read in the reference style with section "schema" allowed, passed with its Required dn and object_classes deleted. The same pages also got findings that called documented fields undocumented: “block part is not documented” and “Read-Only attribute rendered should be documented in Attribute Reference” on cloudinit, whose ## Schema documents both.

Rule. A field’s home sections follow docs/rules/field-homes.md: Argument Reference for a configurable field; Attribute Reference for a computed-only field, or either with allow_inline_read_only; either for a field of a ConfigUnknown block. When every home section of a field is absent from the doc, coverage can’t check it. One finding per missing section reports all such fields:

WARN no ## Argument Reference section, so 3 arguments (attributes, dn, object_classes) aren't checked against the schema

What reports it. Under the default types both checks fire on a missing Argument Reference: section_presence’s “missing required section” error and this warning (TestCoverage_MissingHomeSectionDeferral). Neither depends on the other. When the type doesn’t require the section, or section_presence is off, this warning is the only report, which is the case #117 was about.

4. Bugs found on the way

5. What stays unchecked

Unchecked Why Reported by  
Fields whose every home section is missing Nothing to check them against The §3 warning, which names them; section_presence when the type requires the section  
Description style in the tfplugindocs style Descriptions are the schema’s Nothing by default; description = true turns it back on  
format (code blocks, multi-line and indented bullets, interrupted lists) in ## Schema, and in any reference section whose heading isn’t exactly ## Argument Reference or ## Attribute Reference (## Arguments Reference and ## Attributes Reference on azurerm and google, a configured attributes_heading) checkFormat finds sections by heading text, not from the parsed sections. Pre-existing for azurerm and google; scanning by parsed section would add findings there that need their own corpus review Nothing #125
Labels and order of function arguments Positional, unlabeled signature_section for the signature; §2 for presence both ways  
A root id without a description listed under Read-Only or under its flag’s group Both are what tfplugindocs writes Nothing, by design  
Docs written in the other style One style per provider Their sections are unknown sections (section_presence) and the §3 warning  

6. Measured

Corpus: each provider’s docs at the tag of its latest registry release, with that release’s schema. Each run uses a config with only provider_source, then adds doc_style = "tfplugindocs". Errors/warnings; every run twice, identical.

Provider Base 716ac6d Branch, reference style Branch, tfplugindocs style
hashicorp/archive 2.8.1 24/0 8/4 0/0
hashicorp/cloudinit 2.4.1 12/0 8/4 0/0
hashicorp/dns 3.6.2 91/0 80/24 0/0
elastic-infra/ldap 2.0.1 6/0 6/1 0/0
hashicorp/local 2.9.1 62/0 28/13 0/0
hashicorp/random 3.9.1 82/0 64/23 0/0
hashicorp/null 3.3.2 10/0 8/3 2/0
hashicorp/time 0.14.2 53/7 31/14 2/7
hashicorp/http 3.6.3 12/0 7/2 3/0
hashicorp/tls 4.4.2 75/0 36/16 7/0
cloudflare/cloudflare 5.29.0 6,993/0 3,687/1,502 23/0
DataDog/datadog 4.30.0 2,536/2 1,447/384 67/2
hashicorp/kubernetes 3.5.0 1,352/145 787/339 643/143
hashicorp/tfe 0.84.0 (mostly reference style) 904/82 667/258 158/81
integrations/github 6.13.0 (mostly reference style) 1,378/150 1,335/188 467/254
hashicorp/google 8.11.0 32,219/34,031 32,171/34,035  
hashicorp/azurerm 5.14.0 36,998/5,236 36,998/5,236  

In the reference style, the drop on tfplugindocs providers is the §3 rule: one warning per missing section in place of a per-field error for each field of a ## Schema page. That style still fails those providers, on titles and sections, as it should; it isn’t their style.

The tfplugindocs-style findings that remain were spot-checked; all are real or come from custom templates. Stale docs: datadog lists auth_config.aws_auth_config_keys fields as Required that the schema made Optional; kubernetes pages lack volume_device and namespace_selector; cloudflare documents a removed filter and lists the computed networks as Optional. Also missing ## Example Usage (cloudflare, datadog, tls), hand-ordered fields (tls), a title code block (cloudflare), deprecated fields not marked, and custom templates: titles without (Resource) (kubernetes, null), ## Schema before ## Example Usage (kubernetes), extra sections (http, tls, time), import blocks with no language (kubernetes). Those are configured with title_format, the type’s section order, and allow_unknown_sections. github and tfe are reference-style providers measured in the wrong style; their pages in the other style are what is reported.

Reference-style providers: