Skip to content

Commit

Permalink
feat: remove docs (#8)
Browse files Browse the repository at this point in the history
BREAKING! cleanup
  • Loading branch information
KazuCocoa authored Apr 27, 2024
1 parent 3e18ae7 commit 3b3cf1d
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 131 deletions.
21 changes: 0 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ Appium::Thor::Config.set do
github_name 'appium_thor'
branch 'master'
version_file 'lib/appium_thor/version.rb'
docs_block do
run 'docs/helpers_docs.md', globs('/lib/appium_thor/helpers.rb')
end
end

# Must use '::' otherwise Default will point to Thor::Sandbox::Default
Expand All @@ -43,7 +40,6 @@ end
|github_name | `#{gem_name}`|
|branch | `master`|
|version_file | `lib/#{gem_name}/version.rb`|
|docs_block | no docs are generated|

`branch` customises the target branch to push changes.
Defaults to `master`
Expand All @@ -60,27 +56,10 @@ thor bump # Bump the z version number and update the date.
thor bumpx # Bump the x version number, set y & z to zero, update the date.
thor bumpy # Bump the y version number, set z to zero, update the date.
thor byte # Remove non-ascii bytes from all *.rb files in the current dir
thor docs # Update docs
thor gem_install # Install gem
thor gem_uninstall # Uninstall gem
thor info # prints config info for this gem
thor notes # Update release notes
thor publish # Build and release a new gem to rubygems.org
thor release # Build and release a new gem to rubygems.org (same as publish)
```

--

# docs_block

The `docs_block` method runs within the `docs.rb` context. Here's a more complex example:

```ruby
common_globs = '/lib/appium_lib/*.rb', '/lib/appium_lib/device/*.rb', '/lib/appium_lib/common/**/*.rb'
android_globs = common_globs + ['/lib/appium_lib/android/**/*.rb']
ios_globs = common_globs + ['/lib/appium_lib/ios/**/*.rb']

run 'docs/android_docs.md', globs(android_globs)

run 'docs/ios_docs.md', globs(ios_globs)
```
5 changes: 1 addition & 4 deletions Thorfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ require File.expand_path '../lib/appium_thor', __FILE__
Appium::Thor::Config.set do
appium_thor = 'appium_thor'
gem_name appium_thor
docs_block do
run 'docs/helpers_docs.md', globs("/lib/#{appium_thor}/helpers.rb")
end
end
end
2 changes: 0 additions & 2 deletions appium_thor.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']

s.add_runtime_dependency 'redcarpet', '~> 3.1', '>= 3.1.2'
s.add_runtime_dependency 'posix-spawn', '~> 0.3', '>= 0.3.8'
s.add_runtime_dependency 'yard', '~> 0.9.11'

s.files = `git ls-files`.split "\n"
end
2 changes: 0 additions & 2 deletions lib/appium_thor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,10 @@

# gems
require 'rubygems'
require 'yard' # docs.rb
require 'posix-spawn' # helpers.rb
require 'date' # helpers.rb Date.today

# internal
require_relative 'appium_thor/docs'
require_relative 'appium_thor/helpers'
require_relative 'appium_thor/version'
require_relative 'appium_thor/config'
Expand Down
5 changes: 0 additions & 5 deletions lib/appium_thor/commands/commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ def gem_install
_install
end

desc 'docs', 'Update docs'
def docs
instance_eval &docs_block if docs_block
end

desc 'notes', 'Update release notes'
def notes
update_release_notes
Expand Down
9 changes: 1 addition & 8 deletions lib/appium_thor/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,9 @@ def init_and_validate
raise "version file doesn't exist #{@version_file}" unless File.exist?(@version_file)
end

# block of code to execute that contains documentation
# generation logic
def docs_block(&block)
return @docs_block if @docs_block
@docs_block = block
end

# Returns all options as symbols. Required for defining delegators in init.rb
def self.options
string_options + [:docs_block]
string_options
end

# the subset of options that operate on strings
Expand Down
82 changes: 0 additions & 82 deletions lib/appium_thor/docs.rb

This file was deleted.

14 changes: 7 additions & 7 deletions lib/appium_thor/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ def _build_gem
# Returns true if the tag exists on the master branch.
def tag_exists(tag_name)
cmd = %Q(git branch -a --contains "#{tag_name}")
POSIX::Spawn::Child.new(cmd).out.include? "* #{branch}"
stdout, status = Open3.capture2(cmd)
stdout.include? "* #{branch}"

end

# Runs command. Raises an exception if the command doesn't execute successfully.
def sh(command)
process = POSIX::Spawn::Child.new command
stdout, stderr, status = Open3.capture3(command)

unless process.success?
raise "Command #{command} failed. out: #{process.out}\nerr: #{process.err}"
unless status.success?
raise "Command #{command} failed. out: #{stdout}\nerr: #{stderr}"
end

out = process.out
out ? out.strip : out
stdout.strip
end

# Used to parse the version number from version_file
Expand Down Expand Up @@ -187,7 +188,6 @@ def _publish

# update notes now that there's a new tag
notes rescue notes_failed = true
docs
sh "git commit --allow-empty -am 'Update release notes'" unless notes_failed
sh "git push origin #{branch}"
sh "git push origin #{tag_name}"
Expand Down

0 comments on commit 3b3cf1d

Please sign in to comment.