Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Html rendering #47

Open
wants to merge 22 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
d7789e2
gem: rvm ruby gemset and version added.
lolgear Feb 13, 2018
eb1543e
gitignore: updated in case of xcode project example project.
lolgear Feb 13, 2018
e5bc6aa
spec: example xcode project added.
lolgear Feb 13, 2018
9a8d14b
gem: html acknowledgements rendering added.
lolgear Feb 13, 2018
bef1e1c
gem: rvm files removed.
lolgear Feb 13, 2018
a455178
gem: fix indentation.
lolgear Feb 13, 2018
694d867
gem: writers html nokogiri dependency removed.
lolgear Feb 13, 2018
d3ee536
gem: gemspec trailing newline added.
lolgear Feb 13, 2018
947f4ca
gemspec: nokogiri dependency removed.
lolgear Feb 13, 2018
3b7c780
changelog: updated.
lolgear Feb 15, 2018
b6e79fa
gem: html generator has been updated.
lolgear Feb 6, 2019
78ecf99
gem: spec assets example project has been updated.
lolgear Feb 6, 2019
c6cdf19
gem: html writer dsl has been added.
lolgear Feb 10, 2019
e571bb6
gem: markdown writer has been added. erb writer variants has been added.
lolgear Feb 10, 2019
b002205
gem: specs assets example project markdown acknowledgements file has …
lolgear Feb 10, 2019
a35e4ad
gem: erb writers variants cleanup.
lolgear Feb 10, 2019
4742148
gem: markdown erb-free writer has been added. gitignore has been fixed.
lolgear Feb 12, 2019
de284c3
gem: html layout module has been added. gitignore ds_store has been a…
lolgear Feb 12, 2019
02dc5fa
gem: markdown render settings have been added. generators have been s…
lolgear Mar 5, 2019
7ca1b48
gem: markdown parser have been removed from writers.
lolgear Mar 5, 2019
5b18d4d
gem: metadata generators have been tangled with writers instead of ba…
lolgear Mar 6, 2019
0dc1721
Merge remote-tracking branch 'upstream/master' into html_rendering.
lolgear Mar 13, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/cocoapods_acknowledgements/html_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ class HTMLGenerator < PlistGenerator
class << self
def generate_specs(target_description, sandbox, excluded, root_specs)
metadata = super
specs = metadata["specs"]
metadata["specs"] = specs.map do |spec|
Generator::SpecObject.new(spec)
end
metadata["header"] = header
metadata["footer"] = footer
metadata
Expand Down
83 changes: 51 additions & 32 deletions lib/cocoapods_acknowledgements/writers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,16 @@ def initialize(&block)
end
end

def tag(tag, &block)
new_object = HTMLObject.tag(tag)
def tag_or_object(tag)
if tag.is_a? HTMLObject
tag
else
HTMLObject.tag tag
end
end

def open(tag)
new_object = tag_or_object tag
unless @root_object
@root_object = new_object
@current_object = @root_object
Expand All @@ -115,30 +122,52 @@ def tag(tag, &block)
@current_object << new_object
@current_object = new_object
end
end

# puts "root_object: #{@root_object.tag_begin}"
# puts "current_object: #{@current_object.tag_begin}"
# puts "parent_object: #{@parent_object.tag_begin}"
def close
@current_object = @parent_object
end

def tag(tag, &block)
self.open tag
if block
block.call(self)
end

@current_object = @parent_object
end

def << (html)
# append html as pure object
@current_object << PureHTMLObject.content(html)
self.close
end

def content(html)
self << html
@current_object << PureHTMLObject.content(html)
end

def to_html
root_object.to_html
end

# MARK: DSL
def > (tag)
self.open tag
self
end
def !
self.close
self
end
def << (html)
self.content(html)
self
end
def >= (tag)
self > tag
!self
end
def <= (html)
self << html
!self
# self.content(html)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented-out code

# self.close
# self
end
end

class << self
Expand All @@ -148,29 +177,19 @@ def file_extension

def write_to_file(metadata, filepath)
# for each component of metadata we should wrap it into appropriate component.
specs = metadata["specs"].map do |spec|
Generator::SpecObject.new(spec)
end
specs = metadata["specs"]
header = metadata["header"]
footer = metadata["footer"]

builder = HTMLObjectBuilder.new do |doc|
doc.tag("html") {
doc.tag("body") {
doc.tag("h1") {
doc << header
}
specs.each do |spec|
doc.tag("h2") {
doc << spec.name
}
doc.tag("p")
license_into_html = MarkdownParser.parse_markdown(spec.licenseText)
doc << license_into_html
end
doc << footer
}
}
doc > "html" > "body"
lolgear marked this conversation as resolved.
Show resolved Hide resolved
doc > "h1" <= header
specs.each do |spec|
doc > "h2" <= spec.name
doc >= "p"
doc << MarkdownParser.parse_markdown(spec.licenseText)
end
doc <= footer
end

content = builder.to_html
Expand Down