class Semverve::DocsPublisher
Publishes generated documentation to a Git branch through a temporary worktree.
Attributes
Whether dirty source working trees are allowed.
@return [Boolean]
Branch that receives generated documentation.
@return [String]
Command runner used for Git commands.
@return [#run, #capture, #success?]
Commit message for generated documentation updates.
@return [String]
Whether to report changes without committing or pushing.
@return [Boolean]
Output stream for status messages.
@return [#puts]
Whether the publishing branch should be pushed.
@return [Boolean]
Remote used when pushing the publishing branch.
@return [String]
Source project root.
@return [String]
Directory containing generated documentation, relative to root.
@return [String]
Documentation directory on the publishing branch.
@return [String]
Optional path for the temporary worktree.
@return [String, nil]
Public Class Methods
Source
# File lib/semverve/docs_publisher.rb, line 150 def initialize @root = Dir.pwd @source_dir = "docs" @target_dir = "docs" @branch = "gh-pages" @remote = "origin" @commit_message = "Update generated documentation" @worktree_path = nil @allow_dirty = false @push = true @dry_run = false @command_runner = Shell.new @output = $stdout yield self if block_given? end
Initializes a documentation publisher.
@yieldparam [Semverve::DocsPublisher] publisher
@return [Semverve::DocsPublisher]
Public Instance Methods
Source
# File lib/semverve/docs_publisher.rb, line 171 def publish validate! ensure_clean_source_worktree unless allow_dirty with_worktree do |worktree| sync_docs_to(worktree) unless publishing_worktree_changed?(worktree) output.puts "Documentation is already current on #{branch}." return false end if dry_run output.puts "Documentation changes detected for #{branch}; dry run did not commit or push." return true end commit_docs(worktree) push_docs(worktree) if push output.puts "Published documentation to #{remote}/#{branch}." true end end
Publishes generated documentation.
@return [Boolean] whether documentation changes were found