Class: Semverve::DocsPublisher::Task

Inherits:
Object
  • Object
show all
Includes:
Rake::DSL
Defined in:
lib/semverve/docs_publisher/task.rb

Overview

Defines Rake tasks for publishing generated documentation.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|task| ... } ⇒ Semverve::DocsPublisher::Task

Initializes and defines documentation publishing tasks.

Yield Parameters:



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/semverve/docs_publisher/task.rb', line 92

def initialize
  @root = Dir.pwd
  @build_task = "rerdoc"
  @source_dir = "docs"
  @target_dir = "docs"
  @branch = "gh-pages"
  @remote = "origin"
  @commit_message = "Update generated documentation"
  @worktree_path = nil
  @allow_dirty = false
  @push = true
  @output = $stdout
  @task_namespace = :docs

  yield self if block_given?

  define
end

Instance Attribute Details

#allow_dirtyBoolean

Whether dirty source working trees are allowed.

Returns:

  • (Boolean)


66
67
68
# File 'lib/semverve/docs_publisher/task.rb', line 66

def allow_dirty
  @allow_dirty
end

#branchString

Branch that receives generated documentation.

Returns:

  • (String)


42
43
44
# File 'lib/semverve/docs_publisher/task.rb', line 42

def branch
  @branch
end

#build_taskString

Rake task that builds documentation before publishing.

Returns:

  • (String)


24
25
26
# File 'lib/semverve/docs_publisher/task.rb', line 24

def build_task
  @build_task
end

#commit_messageString

Commit message for generated documentation updates.

Returns:

  • (String)


54
55
56
# File 'lib/semverve/docs_publisher/task.rb', line 54

def commit_message
  @commit_message
end

#output#puts

Output stream for status messages.

Returns:

  • (#puts)


78
79
80
# File 'lib/semverve/docs_publisher/task.rb', line 78

def output
  @output
end

#pushBoolean

Whether the publishing branch should be pushed.

Returns:

  • (Boolean)


72
73
74
# File 'lib/semverve/docs_publisher/task.rb', line 72

def push
  @push
end

#remoteString

Remote used when pushing the publishing branch.

Returns:

  • (String)


48
49
50
# File 'lib/semverve/docs_publisher/task.rb', line 48

def remote
  @remote
end

#rootString

Source project root.

Returns:

  • (String)


18
19
20
# File 'lib/semverve/docs_publisher/task.rb', line 18

def root
  @root
end

#source_dirString

Directory containing generated documentation.

Returns:

  • (String)


30
31
32
# File 'lib/semverve/docs_publisher/task.rb', line 30

def source_dir
  @source_dir
end

#target_dirString

Documentation directory on the publishing branch.

Returns:

  • (String)


36
37
38
# File 'lib/semverve/docs_publisher/task.rb', line 36

def target_dir
  @target_dir
end

#task_namespaceSymbol, String

Namespace for the generated tasks.

Returns:

  • (Symbol, String)


84
85
86
# File 'lib/semverve/docs_publisher/task.rb', line 84

def task_namespace
  @task_namespace
end

#worktree_pathString?

Optional path for the temporary worktree.

Returns:

  • (String, nil)


60
61
62
# File 'lib/semverve/docs_publisher/task.rb', line 60

def worktree_path
  @worktree_path
end

Instance Method Details

#definevoid

This method returns an undefined value.

Defines the documentation publishing tasks.



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/semverve/docs_publisher/task.rb', line 115

def define
  namespace namespace_name do
    desc "Publish generated documentation to #{branch}"
    task :publish do
      publish(dry_run: false)
    end

    namespace :publish do
      desc "Show whether generated documentation would change #{branch}"
      task :dry_run do
        publish(dry_run: true)
      end
    end
  end
end