Skip to content

Commit

Permalink
show service descriptions in each client document (#2544)
Browse files Browse the repository at this point in the history
* show service descriptions in each client document

* better handle the formated string where {} could be escaped
  • Loading branch information
AllanZhengYP committed Feb 21, 2019
1 parent 8fc4535 commit a874567
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions doc-src/templates/api-versions/model_documentor.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
require 'ostruct'

module Documentor
def service_overview(rules)
docs = documentation(rules)
docs = docs || '';
docs = docs.gsub(/<fullname>.+?<\/fullname>/, '')
docs = docs.gsub(/(.*?)\{(\S*?)\}/, '\1[\2]') ## replace {} in format string with []
if docs && (docs.include? 'runtime aspects of your deployed APIs')
puts docs
end
docs == '' ? nil : docs
end

def documentation(rules)
docs = rules['documentation'] || ''
docs = docs.gsub(/<!--.*?-->/m, '')
Expand Down Expand Up @@ -37,12 +48,25 @@ class ModelDocumentor

def initialize(klass, api)
api_version = api['metadata']['apiVersion']
service_desc = service_overview(api)
@lines = []
@lines << ''
@lines << <<-DOCS.strip
Constructs a service interface object. Each API operation is exposed as a
function on service.
DOCS

if service_desc
@lines << <<-DOCS.strip
### Service Description
#{service_desc}
DOCS
end

@lines << <<-DOCS.strip
### Sending a Request Using #{klass}
```javascript
Expand Down

0 comments on commit a874567

Please sign in to comment.