r7kamura / autodoc Goto Github PK
View Code? Open in Web Editor NEWGenerate documentation from your rack application & request-spec.
License: MIT License
Generate documentation from your rack application & request-spec.
License: MIT License
#10 と少し被りますが、自動でドキュメントを生成する設定の追加を検討しています。
基本はgit commitの変更履歴(時間)を見ます。
e.g
spec/spam_spec.rb
が変更のcommitを行い、かつdoc/spam.md
がgit logにないならばspam.md
生成。doc/spam.md
がgit logにあるが、コミットされた時間が
time('doc/spam.md') < time('spec/spam_spec.rb')
ならば、spam.md
を生成。time('doc/spam.md') >= time('spec/spam_spec.rb')
)ならば生成しない。Autodoc.configuration.automatic_doc_generation = true
ならAUTODOC=1 bundle rspec spec/
を実行するときに実行されるようにしたいと考えています。
いかがでしょうか?
I tried to use a customised template by setting the Autodoc.configuration.template
like below:
Autodoc.configuration.template = 'spec/autodoc/templates/document.md.erb'
But this doesn't work because it doesn't take a String value but a File object? (ref:
autodoc/lib/autodoc/configuration.rb
Line 30 in ab3450c
I need to set it like the following to use a customised template
Autodoc.configuration.template = File.read(File.expand_path('../autodoc/templates/document.md.erb', __FILE__))
In the README.md it says
template - [String] ERB template for each document (default: document.md.erb)
So I believe this is a bug.
I'll try to fix this later when I have time.
via https://github.com/r7kamura/autodoc/issues/44、broken symlink seem to be fixed.
but Errno::ELOOP: Too many levels of symbolic links
is still happing.
いまいち解決策が思いつかないんだけど、Fakerとかを使ってて、specごとに変わってしまう文字列に影響されてドキュメントが更新されるのが面倒。
変更内容をチェックしてリポジトリにコミットしなければいいだけといえばそれまでなんだけど。
I tryed to generate a doc from other than request-specs.
In this case, Autodoc succeeded in generating a doc, but it didn't have intended filepath.
I think, it should generate a doc from only residing spec/requests.
How do you think?
$ cat spec/controllers/api/v1/workbooks_controller_spec.rb
require 'rails_helper'
RSpec.describe Api::V1::WorkbooksController, type: :controller do
render_views
describe '#index' do
context 'has workbooks' do
before do
@workbook = create(:workbook)
get :index, format: :json
end
it 'get workbook list', autodoc: true do
expect(response.status).to eq 200
end
end
end
end
$ AUTODOC=1 bundle exec rspec
$ tree doc
doc
└── spec
└── controllers
└── api
└── v1
└── workbooks_controller_spec.rb
Would you add .travis.yml
?
Hi,
I'm trying to use this with spring like this:
AUTODOC=1 spring rspec --color spec/requests/users_spec.rb
but it generates nothing.
I need to use it without spring like this
AUTODOC=1 rspec --color spec/requests/users_spec.rb:19
to make it generate docs.
I'm not sure if this is autodoc's or spring's issue?
Thanks
一つの同じContextの中でinclude_examplesし、その中でdescriptionを定義すると、後勝ちでdescriptionが上書きされます。
以下のような:point_down:の内容を実行したところこのバグを発見しました。
require 'rails_helper'
RSpec.describe 'Users', :autodoc do
describe 'GET /users/:user_id' do
let(:user) { create(:user) }
shared_examples 'page not found' do
it { is_expected.to eq(404) }
end
shared_examples 'page accesable ' do
it { is_expected.to eq(200) }
end
include_examples 'page not found' do
let(:user_id) { user.tap(&:destroy).id }
let(:description) { 'When user is not exist' }
end
include_examples 'page accesable' do
let(:user_id) { user.id }
let(:description) { 'When user exist' }
end
end
end
## GET /users/:user_id
- When user exist
### Example
#### Request
...
## GET /users/:user_id
- When user exist
### Example
#### Request
rubygems/rubygems#2516
こちらのPRにより、spec/dummy/spec
にはられているシンボリックリンクがおかしくなっていたのが修正されたので、versionを変えて再リリースをお願いしたいです。
/usr/local/bundle/gems/autodoc-0.7.6/lib/autodoc/document.rb:30: warning: Passing safe_level with the 2nd argument of ERB.new is deprecated. Do not use it, and specify other arguments as keyword arguments.
/usr/local/bundle/gems/autodoc-0.7.6/lib/autodoc/document.rb:30: warning: Passing trim_mode with the 3rd argument of ERB.new is deprecated. Use keyword argument like ERB.new(str, trim_mode: ...) instead.
DEPRECATION WARNING: Rails 7.1 will return Content-Type header without modification. If you want just the MIME type, please use `#media_type` instead. (called from load at /usr/local/bundle/bin/rspec:25)
Hi,
I noticed that in https://github.com/r7kamura/autodoc/blob/master/spec/dummy/doc/recipes.md, there are something like
But in
https://github.com/r7kamura/autodoc/blob/master/spec/requests/recipes_spec.rb
I didn't find any specific syntax to specify this. I'm wondering how to specify the required/optional or other params description?
thanks
/keyword?keyword=和食
のように、query string に multibyte 文字が含まれている際に Encoding::CompatibilityError
が発生していまいます。
$ cat spec/requests/search_spec.rb
require 'rails_helper'
RSpec.describe 'Search', :type => :request do
describe 'GET /search/?keyword=:keyword' do
it 'キーワード検索', :autodoc => true do
get '/search/', params: { :keyword => '和食' }
expect(response.status).to eq 200
end
end
end
$ AUTODOC=1 bundle exec rspec --backtrace
.
An error occurred in an `after(:suite)` hook.
Failure/Error: Unable to find (erb) to read failed line
Encoding::CompatibilityError:
incompatible character encodings: UTF-8 and ASCII-8BIT
# (erb):9:in `concat'
# (erb):9:in `render'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/2.4.0/erb.rb:896:in `eval'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/2.4.0/erb.rb:896:in `result'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/document.rb:30:in `render'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:26:in `map'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:26:in `block (2 levels) in write_documents'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:26:in `open'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:26:in `open'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:26:in `block in write_documents'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:24:in `each'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:24:in `write_documents'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/documents.rb:18:in `write'
# ./vendor/bundle/ruby/2.4.0/gems/autodoc-0.6.1/lib/autodoc/rspec.rb:8:in `block in <top (required)>'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/example.rb:447:in `instance_exec'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/hooks.rb:357:in `run'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1949:in `block in run_suite_hooks'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1947:in `each'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1947:in `run_suite_hooks'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/configuration.rb:1896:in `with_suite_hooks'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:113:in `block in run_specs'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/reporter.rb:79:in `report'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:112:in `run_specs'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:87:in `run'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:71:in `run'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/lib/rspec/core/runner.rb:45:in `invoke'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-core-3.6.0/exe/rspec:4:in `<top (required)>'
# ./vendor/bundle/ruby/2.4.0/bin/rspec:22:in `load'
# ./vendor/bundle/ruby/2.4.0/bin/rspec:22:in `<top (required)>'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:74:in `load'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:74:in `kernel_load'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli/exec.rb:27:in `run'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli.rb:365:in `exec'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor.rb:369:in `dispatch'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli.rb:22:in `dispatch'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/vendor/thor/lib/thor/base.rb:444:in `start'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/cli.rb:13:in `start'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/exe/bundle:30:in `block in <top (required)>'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/lib/bundler/friendly_errors.rb:121:in `with_friendly_errors'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/bundler-1.15.3/exe/bundle:22:in `<top (required)>'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/bin/bundle:22:in `load'
# /Users/uchida/.anyenv/envs/rbenv/versions/2.4.1/bin/bundle:22:in `<main>'
Finished in 2.46 seconds (files took 0.41094 seconds to load)
1 examples, 0 failures, 0 pending, 1 error occurred outside of examples
$ ruby -v
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin15]
$ bundle exec rails -v
Rails 5.1.3
$ grep autodoc Gemfile.lock
Gemfile.lock: autodoc (0.6.1)
Gemfile.lock: autodoc
$ AUTODOC=1 bundle exec rspec spec/requests/api/hoge_spec.rb
...
An error occurred in an `after(:suite)` hook.
Failure/Error: Unable to find (erb) to read failed line
Encoding::CompatibilityError:
incompatible character encodings: ASCII-8BIT and UTF-8
# (erb):16:in `concat'
# (erb):16:in `render'
lib/autodoc/templates/document.md.erb
で以下の値の encoding が US-ASCII
でした。
method
request_query
request_body_section
response.status
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.