docit 0.3.0 → 0.3.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19ca1ea84419aa3ec1c1605fec67c6355027d866de1b9e6b0d8fb27472b91602
4
- data.tar.gz: a8fc557d32361a3729a9133791100bea3c7bf94e4c2f0ca55351eff4760efafe
3
+ metadata.gz: 3ac8acf7fd2b736bb2c89c63a63bca482239783457d7572d864e0257a3a2c6cd
4
+ data.tar.gz: 1605b07b832dc73f4e7f00e0840aa72267cbb60262e17baba6842134ee576e19
5
5
  SHA512:
6
- metadata.gz: 4614b2cc382920b578400ddbccb8afb0eb8a32830307e0fd75fc3a175678f218d7f658e82b61678422d520c6f6c841fa5643d36d563b6cacf0bd4233bbed655f
7
- data.tar.gz: fe46a50539ba08a2783b8e1f4d95a2e313fc1a043f78dee017ad4dd47cba8166f5cb8341bf5cbf732b4e7f7a776e9966e12efcce4c1a1b3a3b2c08cf2887acf1
6
+ metadata.gz: a72fa34e950fdf918daab680c287311401a4059fa3b8d0bf16a0ebcef210ed607b697d3ad58a3343bf7d105a2a11d717efd0f8ee239464a82f58ca5f934b1e79
7
+ data.tar.gz: 96516820d968faae672a4caa7b6c52c9d79356b6366d09edaa019badb2c6949c0b4087115e6f306f559904b5dbcb02b594c2e0e58e864458c0c460e381d4d894
data/README.md CHANGED
@@ -5,6 +5,12 @@
5
5
 
6
6
  Decorator-style API documentation for Ruby on Rails. Write OpenAPI 3.0.3 docs with clean controller DSL macros, separate doc modules, or AI-assisted scaffolding for undocumented endpoints.
7
7
 
8
+ ### Scalar (default)
9
+ ![Scalar API Reference](docs/images/scalar_image.png)
10
+
11
+ ### Swagger
12
+ ![Swagger UI](docs/images/swagger_image.png)
13
+
8
14
  ## Table Of Contents
9
15
 
10
16
  - Getting started
Binary file
Binary file
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Docit
4
+ module Ai
5
+ class InvalidDocBlockError < Error; end
6
+
7
+ class DocBlockValidator
8
+ def initialize(controller:, action:, doc_block:)
9
+ @controller = controller
10
+ @action = action.to_sym
11
+ @doc_block = doc_block
12
+ end
13
+
14
+ def validate!
15
+ doc_module = Module.new
16
+ doc_module.extend(Docit::DocFile)
17
+ doc_module.module_eval(@doc_block, "(generated Docit block)", 1)
18
+
19
+ validate_actions!(doc_module.actions)
20
+
21
+ operation = Docit::Operation.new(controller: @controller, action: @action)
22
+ operation.instance_eval(&doc_module[@action])
23
+
24
+ true
25
+ rescue SyntaxError, StandardError => e
26
+ raise InvalidDocBlockError, error_message_for(e)
27
+ end
28
+
29
+ private
30
+
31
+ def validate_actions!(actions)
32
+ return if actions == [@action]
33
+
34
+ raise InvalidDocBlockError, "Generated output did not define a doc block" if actions.empty?
35
+
36
+ action_list = actions.map { |action| ":#{action}" }.join(", ")
37
+ raise InvalidDocBlockError,
38
+ "Generated output must define only doc :#{@action}, got #{action_list}"
39
+ end
40
+
41
+ def error_message_for(error)
42
+ return error.message if error.is_a?(InvalidDocBlockError)
43
+
44
+ "#{error.class}: #{error.message}"
45
+ end
46
+ end
47
+ end
48
+ end
data/lib/docit/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Docit
4
- VERSION = "0.3.0"
4
+ VERSION = "0.3.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: docit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - S13G
@@ -43,12 +43,15 @@ files:
43
43
  - Rakefile
44
44
  - app/controllers/docit/ui_controller.rb
45
45
  - config/routes.rb
46
+ - docs/images/scalar_image.png
47
+ - docs/images/swagger_image.png
46
48
  - lib/docit.rb
47
49
  - lib/docit/ai.rb
48
50
  - lib/docit/ai/anthropic_client.rb
49
51
  - lib/docit/ai/autodoc_runner.rb
50
52
  - lib/docit/ai/client.rb
51
53
  - lib/docit/ai/configuration.rb
54
+ - lib/docit/ai/doc_block_validator.rb
52
55
  - lib/docit/ai/doc_writer.rb
53
56
  - lib/docit/ai/gap_detector.rb
54
57
  - lib/docit/ai/groq_client.rb
@@ -83,7 +86,7 @@ licenses:
83
86
  metadata:
84
87
  homepage_uri: https://github.com/S13G/docit
85
88
  source_code_uri: https://github.com/S13G/docit
86
- changelog_uri: https://github.com/S13G/docit/blob/main/CHANGELOG.md
89
+ changelog_uri: https://github.com/S13G/docit/blob/master/CHANGELOG.md
87
90
  documentation_uri: https://rubydoc.info/gems/docit
88
91
  bug_tracker_uri: https://github.com/S13G/docit/issues
89
92
  rubygems_mfa_required: 'true'