-
Notifications
You must be signed in to change notification settings - Fork 68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow setting subcategory from code #156
Comments
How can we help support this feature ? |
I actually recently implemented this in a fork of this repo at https://github.com/fbreckle/terraform-plugin-docs I find this approach invasive enough that I did not make a PR in in this repo, though if the maintainers of this repo are interested, I can surely create a merge request. |
This patch adds a --subcategory flag that let users give a mapping that will use to set the `subcategory` field in the documentation: tfplugindocs generate --subcategory consul_acl=ACL --subcategory consul_admin="Admin Partition" The format for the flag is `prefix="Sub Category"` so all resources and datasources starting with `consul_acl` like `consul_acl_policy`, `consul_acl_token`, etc. will have the `subcategory: "ACL"` in the generated documentation. This is not very elegant but should work in most cases as needed. Closes hashicorp#156
Hi all! 👋🏻 Thanks for creating this issue and sorry about the delayed response. We don't have a clear path for solving this issue yet and I'll try to give more context as to why. The current Apologies that this might not be the answer you're looking for, but hopefully it gives you useful context into how we're planning on approaching the problem. |
Hi, thanks for your response! Actually, my fork is working quite fine for the time being. As long as there is some awareness for this issue, I'm fine. I thought a solution would be to add a That said, I really did not put too much tought into this :D and also I did not yet get to use the framework, I still use the SDKv2. Just my two cents, I guess. I will see what you guys come up with. |
In case it helps anyone still having this issue, my workaround is to update the template ---
page_title: "{{.Name}} {{.Type}} - {{.ProviderName}}"
{{ if gt (len (split .Description " --- ")) 1 -}}
subcategory: "{{ index (split .Description " --- ") 0 }}"
{{- else -}}
subcategory: ""
{{- end }}
description: |-
{{ if gt (len (split .Description " --- ")) 1 -}}
{{ index (split .Description " --- ") 1 | plainmarkdown | trimspace | prefixlines " " }}
{{- else -}}
{{ .Description | plainmarkdown | trimspace | prefixlines " " }}
{{- end }}
---
# {{.Name}} ({{.Type}})
{{ if gt (len (split .Description " --- ")) 1 -}}
{{ index (split .Description " --- ") 1 | trimspace }}
{{ else }}
{{ .Description | trimspace }}
{{- end }}
{{ if .HasExample -}}
## Example Usage
{{ tffile (printf "%s%s%s" "examples/resources/" .Name "/resource.tf") }}
{{- end }}
{{ .SchemaMarkdown | trimspace }}
{{- if .HasImport }}
## Import
Import is supported using the following syntax:
{{ codefile "shell" (printf "%s%s%s" "examples/resources/" .Name "/import.sh") }}
{{- end }} This allows me to define resources descriptions with The only caveat is that People can't write |
Hi,
per the docs, subcategories can be used to add some structure to the docs.
The default template defaults to
""
, which I could then manually adjust.The problem with this is this: I maintain a provider with many external contributions are via pull requests. We have a pipeline that enforces that the documentation is updated by running
tfplugindocs
on the PR and then erroring if there are any changes. This means the author of the PR themselves must runtfplugindocs
if they introduce a new attribute or resource to update the docs in their PR.This means managing the subcategory manually is not an option.
The text was updated successfully, but these errors were encountered: