I am using Ruby on Rails 3.0.7 and I would like to install and use a new RDoc template (instead of the default) in order to documenting my application.
I would like to choose one of following:
http://api.rubyonrails.org/
http://www.ruby-doc.org/core/
... others that you advice
So,
Where I can get one of the above templates?
How can I install that?
What code should I put in a .rake file to generate the documentation with the chosen template?
In few words, I am a newbie in this matters.
At this time in my Gemfile I have stated the following:
gem "rdoc", "~> 3.6.1"
and run the bundle install command.
UPDATE I for #dmarkow
I installed the horo gem and inserted the following code in a my .rake file
RDoc::Task.new do |rdoc|
rdoc.title = "My Awesome docs"
rdoc.rdoc_dir = 'doc'
rdoc.options << '-f' << 'horo'
rdoc.options << '--main' << 'README'
end
If I run the command rdoc -f horo --main README.rdoc *.rdoc lib ext I get this:
file '*.rdoc' not found
file 'ext' not found
uh-oh! RDoc had a problem:
Directory doc already exists, but it looks like it isn't an RDoc directory.
Because RDoc doesn't want to risk destroying any of your existing files,
you'll need to specify a different output directory name (using the --op <dir>
option)
If I run the command rake doc:app I get this:
WARNING: Deprecated reference to top-level constant 'Task' found at: <my_application_projectfolder>/Rakefile:7:in `<top (required)>'
Use --classic-namespace on rake command
or 'require "rake/classic_namespace"' in Rakefile
rake aborted!
wrong number of arguments (0 for 2)
UPDATE II for #dmarkow
I removed the doc directory:
If I run the command rdoc -f horo --main README.rdoc *.rdoc lib ext I get this:
file '*.rdoc' not found
file 'ext' not found
No newer files.
Files: 0
Classes: 0 (0 undocumented)
Modules: 0 (0 undocumented)
Constants: 0 (0 undocumented)
Attributes: 0 (0 undocumented)
Methods: 0 (0 undocumented)
Total: 0 (0 undocumented)
0.00% documented
In the documentation directory it creates a created.rid file.
If I run the command rake doc:app I get the same as in the following UPDATE.
What I have to do? I have still to keep the gem "rdoc", "~> 3.6.1" in my Gemfile?
I prefer Hanna, resp Hanna-nouveau.
Hanna was fine, but it is based on an old rdoc-version. Hanna-nouveau base on the original Hanna, but it works with rdoc 3 (tested with rdoc 3.12).
It looks like
You may see another example in http://gems.rubypla.net/todonotes/0.1.0/
Details can be found at https://github.com/rdoc/hanna-nouveau. The Readme contains information about installation and usage.
Update 2014
Hanna-nouveau does not work with rdoc 4.
What you can do: Install an old rdoc-version (I use 3.12). There is no need to uninstall the most actual version. You can call rdoc version depending:
rdoc _3.12_ -f hanna [...more options...]
With _3.12_ the rdoc-version 3.12 is loaded. With -f hanna hanna-nouveau is used.
The one used at http://api.rubyonrails.org is the "Horo" template. You can find it here, along with instructions for using it (it's installed via a gem):
https://github.com/tenderlove/horo
Related
OS X Mavericks
Ruby 1.8.7
Rails 2.3.18
Rspec 1.3.2
Rspec-rails 1.3.4
Output of rake spec
$ rake spec
(in /Users/timosand/Dropbox/Development/epassi)
Please install RDoc 2.4.2+ to generate documentation.
DEPRECATION WARNING: Rake tasks in vendor/plugins/annotate_models/tasks, vendor/plugins/barcode_generator/tasks, vendor/plugins/crypted_authentication/tasks, vendor/plugins/oauth-plugin/tasks, vendor/plugins/tarantula/tasks, and vendor/plugins/ym4r_gm/tasks are deprecated. Use lib/tasks instead. (called from /usr/local/var/rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/rails-2.3.18/lib/tasks/rails.rb:10)
DEPRECATION WARNING: ActiveSupport::Dependencies.load_paths is deprecated, please use autoload_paths instead. (called from /usr/local/var/rbenv/versions/1.8.7-p375/lib/ruby/gems/1.8/gems/carrierwave-0.4.10/lib/carrierwave.rb:84)
/Users/timosand/Dropbox/Development/epassi/config/initializers/oauth_consumers.rb:7: warning: already initialized constant VERSION
/Users/timosand/Dropbox/Development/epassi/lib/spreadsheet/format.rb:21: warning: already initialized constant COLORS
I have 45 spec files
$ find spec -name '*_spec.rb' | wc -l
45
I've added p __FILE_ to each spec and every filename gets printed. Still the actual tests are not run.
Any advice on how to solve this?
Here is my spec_helper.rb and one controller spec as an example
I have a new Ruby on Rails installation where I can see the default start-page.
I followed this guide in order to install MongoDB to Rails.
Now I get this error when running rake test:
**Notice: C extension not loaded. This is required for optimum MongoDB Ruby driver performance.
You can install the extension as follows:
gem install bson_ext
If you continue to receive this message after installing, make sure that the
bson_ext gem is in your load path and that the bson_ext and mongo gems are of the same version.
I have installed the bson_ext gem, which means that now bson_ext in not in my load path or that the gems are not the same version.
Where is the load path? How can I change it?
How do I check if the gems are the same version?
If you're using Ruby on Rails 3+, you should check that the bson_ext gem is referenced in your Gemfile.
Open up Gemfile (in your rails app's root directory) and add a line that says: bson_ext
You should have:
gem mongo
gem bson_ext
Also here is some more info from 10gen docs on running tests in rails:
Running Tests
A slight modification is required to get rake test working (thanks to John P. Wood). Create a file lib/tasks/mongo.rake containing the following:
namespace :db do
namespace :test do
task :prepare do
# Stub out for MongoDB
end
end
end
Now the various rake test tasks will run properly. See John's post for more details.
They also reference John Wood's post which is quite good.
I'm trying to use collectiveidea's delayed_job gem
The installation instructions include
Rake tasks are not automatically loaded from gems, so you’ll need to add
the following to your Rakefile:
begin
require 'delayed/tasks'
rescue LoadError
STDERR.puts "Run `rake gems:install` to install delayed_job"
end
Where is my Rakefile? And what is a Rakefile?
I had the same problem with rails 3.1 and collectiveidea-delayed_job.
Once I added Delayed::Worker.backend = :active_record in the initializer I got the error
no such file to load -- delayed/backend/active_record (LoadError)
The solution for me was to add gem 'delayed_job_active_record' in the gemfile, as suggested here
I have the same problem and put that code in delayed_job.rake in the lib/tasks directory. It works, but now It say's:
*** Starting job worker localhost pid:79949
rake aborted!
uninitialized constant Delayed::Job
What is wrong now?
UPDATE: I just got a mail answer from Brandon:
Theres a bug in the latest version where it doesn't get properly initialized when using the rake task. If you create a file in config/initializers and put the follow in it, the error should go away:
Delayed::Worker.backend = :active_record
The Rakefile is a file that is used to configure rake, a Ruby build tool (sort of like make, but all in Ruby). In a Rails project, there is a file in the top project directory named Rakefile where you can insert this code.
Alternatively, you can add a file into the lib/tasks directory (for example named delayed_job.rake) and put the code into there. The name of the file is not important as long as
It is in the lib/tasks directory
It has the extension .rake
I am using the gem whenever
To update the crontab, it executes the whenever command in the root directory of my application.
The trouble is: my production environment doesn't have the gem installed, so I unpacked the whenever gem into my application and running 'whenever' from my application root directory fails to find the file
How do I run the frozen gem executable from the root directory of my application?
I found that
cd #{release_path} && /usr/bin/ruby #{release_path}/script/runner #{release_path}/vendor/gems/whenever-0.4.1/bin/whenever --update-crontab #{application}
works; but this seems like the 'wrong' answer
This has the answer you're looking for:
http://www.mail-archive.com/rubyonrails-talk#googlegroups.com/msg45169.html
Finally, you usually can add gems to
the load path by doing the following
within your environment.rb:
Option 1: add gems using less ruby
code within the environment.rb file
# Add additional load paths for your
own custom dirs config.load_paths +=
%W( #{RAILS_ROOT}/extras )
Option 2: add gems using more ruby
code within the environment.rb file
Dir.glob( File.expand_path(
"#{RAILS_ROOT}/vendor/gems/*",
FILE) ).each do | gem |
$:.unshift File.join( gem, 'lib' ) end
Option 3: using a combination of
Option (1) and (2).
Read the whole message, it's quite instructive.
I tried to update the specs on a gem that didn't have a .specification file.
1. cd {application_home_directory}
2. rake gems:refresh_specs
When I did, I received the recursive warning:
config.gem: Unpacked gem in vendor/gems has no specification file.
Run 'rake gems:refresh_specs' to fix this.
I've also tried this, which also fails to create a specification without any error/warning:
1. cd vendor/gems/gemname
2. gem specification gemname > .specification
What could prevent the creation of a gem specification file in these cases?
Do you have config.gem statements for your gems in your environment.rb file? In my experience, you need to have the gems set up in your configuration in order for rake gems:refresh_specs to know about them.