Skip to content
Snippets Groups Projects
Commit 4233bcc5 authored by Jessica Yao's avatar Jessica Yao
Browse files

parse short description for prototypes


Signed-off-by: default avatarJessica Yao <jessica@heptio.com>
parent 6ee8849d
No related branches found
No related tags found
No related merge requests found
...@@ -18,11 +18,12 @@ import ( ...@@ -18,11 +18,12 @@ import (
// //
const ( const (
apiVersionTag = "@apiVersion" apiVersionTag = "@apiVersion"
nameTag = "@name" nameTag = "@name"
descriptionTag = "@description" descriptionTag = "@description"
paramTag = "@param" shortDescriptionTag = "@shortDescription"
optParamTag = "@optionalParam" paramTag = "@param"
optParamTag = "@optionalParam"
) )
func FromJsonnet(data string) (*SpecificationSchema, error) { func FromJsonnet(data string) (*SpecificationSchema, error) {
...@@ -97,7 +98,7 @@ func FromJsonnet(data string) (*SpecificationSchema, error) { ...@@ -97,7 +98,7 @@ func FromJsonnet(data string) (*SpecificationSchema, error) {
openText = bytes.Buffer{} openText = bytes.Buffer{}
openText.WriteString(strings.TrimSpace(split[1])) openText.WriteString(strings.TrimSpace(split[1]))
switch split[0] { switch split[0] {
case apiVersionTag, nameTag, descriptionTag, paramTag, optParamTag: // Do nothing. case apiVersionTag, nameTag, descriptionTag, shortDescriptionTag, paramTag, optParamTag: // Do nothing.
default: default:
return nil, fmt.Errorf(`Line in prototype heading comment is formatted incorrectly; '%s' is not return nil, fmt.Errorf(`Line in prototype heading comment is formatted incorrectly; '%s' is not
recognized as a tag. Only tags can begin lines, and text that is wrapped must recognized as a tag. Only tags can begin lines, and text that is wrapped must
...@@ -186,6 +187,11 @@ func (s *SpecificationSchema) addField(tag, text string) error { ...@@ -186,6 +187,11 @@ func (s *SpecificationSchema) addField(tag, text string) error {
return fmt.Errorf("Prototype heading comment has two '@description' fields") return fmt.Errorf("Prototype heading comment has two '@description' fields")
} }
s.Template.Description = text s.Template.Description = text
case shortDescriptionTag:
if s.Template.ShortDescription != "" {
return fmt.Errorf("Prototype heading comment has two '@shortDescription' fields")
}
s.Template.ShortDescription = text
case paramTag: case paramTag:
// NOTE: There is usually more than one `@param`, so we don't // NOTE: There is usually more than one `@param`, so we don't
// check length here. // check length here.
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment