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.
Files changed (5) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +29 -2
  3. data/lib/cdoc.rb +11 -4
  4. data/lib/cdoc/version.rb +1 -1
  5. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 99ec20f3098508dd105d537e7be9564ccdd47896
4
- data.tar.gz: 29a4e5e29b73d966d17a090dcca9d5475ba1a8d2
3
+ metadata.gz: c5f4b354e7e92871ae1929676d97e545ad8be1c4
4
+ data.tar.gz: c9112088372b2abe90305b2e5f0dd90b04d7748c
5
5
  SHA512:
6
- metadata.gz: 4f5e7d6e57c6f1ed7c9055bb7914280e0ec6efdaefbae695b6dc35af9ce08fc87faf895c38cfbfd0df0b9c30beaf26cf976a3925ec3b1e327f4443214b01e1cb
7
- data.tar.gz: f8dbc6fc7c3379702c7d03bac526d7f340ca58f0c17965fb372e32874074f35596017567125c7391a704b6cd0d758b099ec4bca56218789907b9c4c475c9a2ff
6
+ metadata.gz: 4adfd8b396b11d9c29f5288ea27ad2187071406809e78041bd050d81f4ede494f38305a7b58dd58e68edec42b6c9b4239ceaca83328402024b7878945b277f72
7
+ data.tar.gz: e4c3666b68e3ced0cc529db5eeaec74a37796c6d3a16245489884c2f925cfaa508ffd38c6f0e72fba4f2a42243fd05e9380aa73535666ced318559472cb3288b
data/README.md CHANGED
@@ -1,8 +1,35 @@
1
1
  # Cdoc
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/cdoc`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Delete this and the text above, and describe your gem
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
 
@@ -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?(' ') # if the line start with 2 or more spaces
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|
@@ -1,3 +1,3 @@
1
1
  module Cdoc
2
- VERSION = "0.1.3"
2
+ VERSION = "0.1.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cdoc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Deepak Kumar