cdoc 0.1.3 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +29 -2
- data/lib/cdoc.rb +11 -4
- data/lib/cdoc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5f4b354e7e92871ae1929676d97e545ad8be1c4
|
4
|
+
data.tar.gz: c9112088372b2abe90305b2e5f0dd90b04d7748c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4adfd8b396b11d9c29f5288ea27ad2187071406809e78041bd050d81f4ede494f38305a7b58dd58e68edec42b6c9b4239ceaca83328402024b7878945b277f72
|
7
|
+
data.tar.gz: e4c3666b68e3ced0cc529db5eeaec74a37796c6d3a16245489884c2f925cfaa508ffd38c6f0e72fba4f2a42243fd05e9380aa73535666ced318559472cb3288b
|
data/README.md
CHANGED
@@ -1,8 +1,35 @@
|
|
1
1
|
# Cdoc
|
2
2
|
|
3
|
-
|
3
|
+
Cdoc generates a simple single page api documentation from the rails application source code comments.
|
4
|
+
To use cdoc you need to add a directive `#doc` for every comment block in the api.
|
4
5
|
|
5
|
-
|
6
|
+
For example
|
7
|
+
|
8
|
+
```
|
9
|
+
#doc
|
10
|
+
# @endpoint /api/v1/accounts/list
|
11
|
+
# @params
|
12
|
+
# {
|
13
|
+
# user_id: '123456'
|
14
|
+
# }
|
15
|
+
# @response
|
16
|
+
# {
|
17
|
+
# accounts: [
|
18
|
+
# {
|
19
|
+
# id: 100,
|
20
|
+
# account_number: '11111111111',
|
21
|
+
# ifsc_code: 'IFSC111111'
|
22
|
+
# },
|
23
|
+
# {
|
24
|
+
# id: 101,
|
25
|
+
# account_number: '111111111112',
|
26
|
+
# ifsc_code: 'IFSC111112'
|
27
|
+
# }
|
28
|
+
# ]
|
29
|
+
# }
|
30
|
+
```
|
31
|
+
|
32
|
+
The code sections will be highligted if a 2 space indentation is used. Alos if the code section is a valid json then the section will be highlighted.
|
6
33
|
|
7
34
|
## Installation
|
8
35
|
|
data/lib/cdoc.rb
CHANGED
@@ -2,15 +2,14 @@ require 'cdoc/version'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'redcarpet'
|
4
4
|
require 'pygments'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
module Cdoc
|
8
|
+
|
7
9
|
class DocRenderer < Redcarpet::Render::HTML
|
8
10
|
def block_code(code, lang='text')
|
9
11
|
lang = lang && lang.split.first || "text"
|
10
12
|
Pygments.highlight(code, lexer: lang)
|
11
|
-
# output = add_code_tags(
|
12
|
-
# Pygmentize.process(code, lang), lang
|
13
|
-
# )
|
14
13
|
end
|
15
14
|
end
|
16
15
|
|
@@ -39,7 +38,7 @@ module Cdoc
|
|
39
38
|
break
|
40
39
|
elsif m = line.match(/@\w+/) # tag line if it start with @<tag>
|
41
40
|
block = tagged_line(line, m[0])
|
42
|
-
elsif line.start_with?(' ')
|
41
|
+
elsif line.start_with?(' ') # if the line start with 2 or more spaces
|
43
42
|
code_block = []
|
44
43
|
code_block << line.sub(' ', '')
|
45
44
|
|
@@ -125,11 +124,19 @@ module Cdoc
|
|
125
124
|
@doc = DocString.new
|
126
125
|
end
|
127
126
|
|
127
|
+
def sidebar_section(headers)
|
128
|
+
headers.each do |title|
|
129
|
+
title.capitalize
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
128
133
|
def generate
|
129
134
|
@doc.title('Chillr API Documentaion')
|
130
135
|
|
131
136
|
@file_groups = files.group_by { |f| File.basename(f, '_controller.rb') }
|
132
137
|
|
138
|
+
@sidebar = sidebar_section(@file_groups.keys)
|
139
|
+
|
133
140
|
@file_groups.each do |group, files|
|
134
141
|
@doc.section(group.capitalize)
|
135
142
|
files.each do |file|
|
data/lib/cdoc/version.rb
CHANGED