Skip to content

Commit

Permalink
Add README. Improve title option
Browse files Browse the repository at this point in the history
  • Loading branch information
duartepinto committed Jul 24, 2019
1 parent fe45c71 commit 14c1c45
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Jocasta
![Gem](https://img.shields.io/gem/v/jocasta.svg)


Utility to extract a section of a Markdown file and write it into a separate file.

## Installation

`gem install jocasta`

## Usage

`jocasta [input] [output] [level] [section] [...options]`

* __input__ - input markdown file.
* __output__ - Markdown file that will be written.
* __level__ - Level of the section to be extracted (`# Level1` `## Level2` `### Level3`)
* __section__ - Section to be extracted. It will also extract sub-sections inside this section.

Options:
* __--title__ - Title that will replace the section title in the output file. If none, it will use the same title.

Named after [Jocasta Nu](https://starwars.fandom.com/wiki/Jocasta_Nu) from Star Wars.
Based on script made by [ReSwift](https://github.com/ReSwift/ReSwift/blob/master/.scripts/doc-preprocessor)
8 changes: 6 additions & 2 deletions bin/jocasta
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ end
def require_args(args, count)
return unless args.length != count

puts 'usage: docgen [input] [output] [level] [section] [...options]'
puts 'usage: jocasta [input] [output] [level] [section] [...options]'
exit 1
end

Expand Down Expand Up @@ -80,7 +80,11 @@ level_hash = ''
(1..level).each do
level_hash += '#'
end
result = "#{level_hash} #{options[:title]}\n" + result if options[:title]
result = if options[:title]
"#{level_hash} #{options[:title]}\n" + result
else
"#{level_hash} #{section_name}\n" + result
end

# -----

Expand Down
12 changes: 7 additions & 5 deletions jocasta.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ Gem::Specification.new do |s|
s.name = 'jocasta'
s.version = '0.0.1'
s.date = '2019-07-24'
s.summary = "Ruby gem to extract sections of a Markdown file into a separate file."
s.description = "Ruby gem to extract sections of a Markdown file into a separate file."
s.summary = "Utility to extract a section of a Markdown file and write it into a separate file."
s.authors = ["Duarte Pinto"]
s.email = '[email protected]'
s.executables << 'jocasta'
s.homepage =
'https://rubygems.org/gems/jocasta'
s.license = 'Apache-2.0'
s.homepage = 'https://rubygems.org/gems/jocasta'
s.license = 'Apache-2.0'
s.metadata = {
"source_code_uri" => "https://github.com/duartepinto/jocasta",
"bug_tracker_uri" => "https://github.com/duartepinto/jocasta/issues"
}
end

0 comments on commit 14c1c45

Please sign in to comment.