Generate RDoc documentation.

This is currently still very messy and we probably want to work out the
best way to declare what parts of our DSL/what files are "public".

Still, even if this is a WIP I'd rather get something committed sooner
rather than later and start iterating on this as a replacement for
`example_formula.rb` and the formula cookbook.

To test:
```bash
cd $(brew --prefix)/Library/Homebrew && \
  rdoc formula.rb requirement.rb utils.rb &&\
  open doc/index.html
```

Closes Homebrew/homebrew#32470.
This commit is contained in:
Mike McQuaid 2014-09-20 16:07:55 +01:00
parent 2df9b0e7ff
commit 05739585d1
5 changed files with 40 additions and 0 deletions

1
.gitignore vendored
View File

@ -11,6 +11,7 @@
!/bin/brew !/bin/brew
!/share/man/man1/brew.1 !/share/man/man1/brew.1
.DS_Store .DS_Store
/Library/Homebrew/doc
/Library/LinkedKegs /Library/LinkedKegs
/Library/PinnedKegs /Library/PinnedKegs
/Library/Taps /Library/Taps

View File

@ -0,0 +1,17 @@
--- !ruby/object:RDoc::Options
encoding: UTF-8
static_path: []
rdoc_include:
- .
charset: UTF-8
exclude:
hyperlink_all: false
line_numbers: true
main_page:
markup: rdoc
page_dir:
show_hash: false
tab_width: 2
title: Homebrew
visibility: :protected
webcvs:

View File

@ -11,9 +11,11 @@ require 'install_renamed'
require 'pkg_version' require 'pkg_version'
class Formula class Formula
# :startdoc:
include FileUtils include FileUtils
include Utils::Inreplace include Utils::Inreplace
extend Enumerable extend Enumerable
# :stopdoc:
attr_reader :name, :path attr_reader :name, :path
attr_reader :stable, :devel, :head, :active_spec attr_reader :stable, :devel, :head, :active_spec
@ -138,6 +140,8 @@ class Formula
Keg.new(installed_prefix).version Keg.new(installed_prefix).version
end end
# :startdoc:
# The directory in the cellar that the formula is installed to. # The directory in the cellar that the formula is installed to.
# This directory contains the formula's name and version. # This directory contains the formula's name and version.
def prefix(v=pkg_version) def prefix(v=pkg_version)
@ -250,6 +254,8 @@ class Formula
false false
end end
# :stopdoc:
# yields self with current working directory set to the uncompressed tarball # yields self with current working directory set to the uncompressed tarball
def brew def brew
validate_attributes :name, :version validate_attributes :name, :version
@ -315,6 +321,8 @@ class Formula
"#<#{self.class.name}: #{path}>" "#<#{self.class.name}: #{path}>"
end end
# :startdoc:
# Standard parameters for CMake builds. # Standard parameters for CMake builds.
# Using Build Type "None" tells cmake to use our CFLAGS,etc. settings. # Using Build Type "None" tells cmake to use our CFLAGS,etc. settings.
# Setting it to Release would ignore our flags. # Setting it to Release would ignore our flags.
@ -333,6 +341,8 @@ class Formula
] ]
end end
# :stopdoc:
# Deprecated # Deprecated
def python(options={}, &block) def python(options={}, &block)
opoo 'Formula#python is deprecated and will go away shortly.' opoo 'Formula#python is deprecated and will go away shortly.'
@ -492,6 +502,8 @@ class Formula
protected protected
# :startdoc:
# Pretty titles the command and buffers stdout/stderr # Pretty titles the command and buffers stdout/stderr
# Throws if there's an error # Throws if there's an error
def system cmd, *args def system cmd, *args
@ -554,6 +566,8 @@ class Formula
end end
end end
# :stopdoc:
private private
def exec_cmd(cmd, args, out, logfn) def exec_cmd(cmd, args, out, logfn)

View File

@ -3,6 +3,8 @@ require 'dependency'
require 'dependencies' require 'dependencies'
require 'build_environment' require 'build_environment'
# :startdoc:
# A base class for non-formula requirements needed by formulae. # A base class for non-formula requirements needed by formulae.
# A "fatal" requirement is one that will fail the build if it is not present. # A "fatal" requirement is one that will fail the build if it is not present.
# By default, Requirements are non-fatal. # By default, Requirements are non-fatal.
@ -104,6 +106,8 @@ class Requirement
super(cmd, ORIGINAL_PATHS.join(File::PATH_SEPARATOR)) super(cmd, ORIGINAL_PATHS.join(File::PATH_SEPARATOR))
end end
# :stopdoc:
class << self class << self
include BuildEnvironmentDSL include BuildEnvironmentDSL

View File

@ -42,6 +42,8 @@ class Tty
end end
end end
# :startdoc:
def ohai title, *sput def ohai title, *sput
title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose? title = Tty.truncate(title) if $stdout.tty? && !ARGV.verbose?
puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}" puts "#{Tty.blue}==>#{Tty.white} #{title}#{Tty.reset}"
@ -71,6 +73,8 @@ def odie error
exit 1 exit 1
end end
# :stopdoc:
def pretty_duration s def pretty_duration s
return "2 seconds" if s < 3 # avoids the plural problem ;) return "2 seconds" if s < 3 # avoids the plural problem ;)
return "#{s.to_i} seconds" if s < 120 return "#{s.to_i} seconds" if s < 120