From a15eaee78ab186c3b13a79b92b5daaa79cfb7c31 Mon Sep 17 00:00:00 2001 From: Andy Joslin Date: Sat, 8 Mar 2014 20:44:57 -0700 Subject: [PATCH] chore(docs): make service documentation look good --- docs/templates/api/api.template.html | 4 ++ docs/templates/api/directive.template.html | 7 ++-- docs/templates/api/object.template.html | 9 ++++- docs/templates/base.template.html | 2 +- docs/templates/lib/macros.html | 47 +++++++++++++++++----- docs/templates/lib/methods.template.html | 40 +++++++++--------- docs/templates/pages-data.template.html | 6 ++- 7 files changed, 78 insertions(+), 37 deletions(-) diff --git a/docs/templates/api/api.template.html b/docs/templates/api/api.template.html index 5febfc4e7f..ff0f233550 100644 --- a/docs/templates/api/api.template.html +++ b/docs/templates/api/api.template.html @@ -3,7 +3,11 @@ <@ block content @> <@ block header @> + <@ if doc.docType == "directive" @> ## <$ doc.name | dashCase $> + <@ else @> +## <$ doc.name $> + <@ endif @> <@ endblock @> <@ block description @> diff --git a/docs/templates/api/directive.template.html b/docs/templates/api/directive.template.html index 8967a9ec8a..4f7eacaf0c 100644 --- a/docs/templates/api/directive.template.html +++ b/docs/templates/api/directive.template.html @@ -6,9 +6,7 @@ <@ block usage @> ## Usage <@ if doc.usage @> - <$ doc.usage $> - <@ else @> <@ if doc.restrict.element @> @@ -48,6 +46,9 @@ <@- endif @> <@ endblock -@> - <@ include "lib/params.template.html" @> + <@ if doc.params @> +## API +<$ paramTable(doc.params, true) $> + <@ endif @> <@ include "lib/events.template.html" @> <@ endblock @> diff --git a/docs/templates/api/object.template.html b/docs/templates/api/object.template.html index c6a937e7c2..bf8723a9fe 100644 --- a/docs/templates/api/object.template.html +++ b/docs/templates/api/object.template.html @@ -1,12 +1,17 @@ <@ include "lib/macros.html" @> <@ extends "api/api.template.html" @> -<@ block additional @> +<@ block additional @> + +<@ if doc.usage @> +## Usage +<$ doc.usage $> +<@ endif @> <@ if doc.params or doc.returns or doc.this or doc.kind == 'function' -@>

Usage

<@ if doc.usage @> - <$ doc.usage | code $> + <$ doc.usage $> <@ else @> <$ functionSyntax(doc) $> <@ endif @> diff --git a/docs/templates/base.template.html b/docs/templates/base.template.html index 891d2e5aa6..6ec8128ac9 100644 --- a/docs/templates/base.template.html +++ b/docs/templates/base.template.html @@ -1,7 +1,7 @@ --- layout: docs_0.9.0 active: javascript -title: "<$ doc.name | dashCase $>" +title: "<@ if doc.docType == "directive" @><$ doc.name | dashCase $><@ else @><$ doc.name $><@ endif @>" header_sub_title: "<$ doc.docType | capital $> in module <$ doc.module $>" doc: "<$ doc.name $>" --- diff --git a/docs/templates/lib/macros.html b/docs/templates/lib/macros.html index ba18034176..9e893330bc 100644 --- a/docs/templates/lib/macros.html +++ b/docs/templates/lib/macros.html @@ -2,6 +2,37 @@ <@ for typeName in types @><$ typeName | escape $><@ endfor @> <@- endmacro -@> +<@ macro paramTable(params, isDirective) @> + + + + + + + + + + <@ for param in params @> + + + + + + <@ endfor @> + +
<@ if isDirective @>Attr<@ else @>Param<@ endif @>TypeDetails
+ <$ param.name $> + <@ if param.alias @>| <$ param.alias $><@ endif @> + <@ if param.type.optional @>
(optional)
<@ endif @> +
+ <$ param.type.name $> + + <$ param.description | marked $> + <@ if param.default @>

(default: <$ param.default $>)

<@ endif @> +
+<@ endmacro @> + + <@- macro directiveParam(name, type, join, sep) @> <@- if type.optional @>[<@ endif -@> <$ name | dashCase $><$ join $><$ type.description $><$ sep $> @@ -9,21 +40,19 @@ <@ endmacro -@> <@- macro functionSyntax(fn) @> - <@- set sep = joiner(', ') -@> - <@ marked -@> - `<$ fn.name $>(<@- for param in fn.params @><$ sep() $> - <@- if param.type.optional @>[<@ endif -@> - <$ param.name $> - <@- if param.type.optional @>]<@ endif -@> - <@ endfor @>);` - <@- endmarked @> +<@- set sep = joiner(', ') -@> +`<$ fn.name $>(<@- for param in fn.params @><$ sep() $> +<@- if param.type.optional @>[<@ endif -@> +<$ param.name $> +<@- if param.type.optional @>]<@ endif -@> +<@ endfor @>)` <@ endmacro -@> <@- macro typeInfo(fn) -@> - +
<$ typeList(fn.typeList) $><$ fn.description | marked $><$ fn.description $>
<@- endmacro -@> diff --git a/docs/templates/lib/methods.template.html b/docs/templates/lib/methods.template.html index 81b60132f5..a7d63e81ab 100644 --- a/docs/templates/lib/methods.template.html +++ b/docs/templates/lib/methods.template.html @@ -1,27 +1,25 @@ <@- if doc.methods @> -

Methods

- +<@ endfor -@> <@- endif -@> diff --git a/docs/templates/pages-data.template.html b/docs/templates/pages-data.template.html index 397c165ff7..316045b5e5 100644 --- a/docs/templates/pages-data.template.html +++ b/docs/templates/pages-data.template.html @@ -148,7 +148,11 @@ <@ else @> <@ endif @>