hoe-markdown 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +13 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +7 -0
- data/LICENSE.txt +21 -0
- data/README.md +103 -0
- data/Rakefile +6 -0
- data/hoe-markdown.gemspec +25 -0
- data/lib/hoe/markdown.rb +61 -0
- data/lib/hoe/markdown/util.rb +64 -0
- data/lib/hoe/markdown/version.rb +5 -0
- metadata +60 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 6cb9e4c8f53ee98f050766c035755003dbe76403b1625b0e90dfb00eccc7930a
|
4
|
+
data.tar.gz: 97069f8181dff7b9b32bf710a55f959788b7169830e5bf6918a721c2326b1c7e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33ef8ee4cb89cdafc82cfea1f9dbb0ea94380ca6fe6350abca751b9a55ec7a0d257943b1dd6340d86d3d87089361a66f420cf1f612ac77e0e123fc67c5f32086
|
7
|
+
data.tar.gz: 5dcfe24d87131804e1b49f0cd1c91cdf3e804682feb31f8ddfa2a4c538542afe304dffb2ec9dabbec9d423a4abcf5782e3f6f617a76c9a1599ec421435266b3c
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
In the interest of fostering an open and welcoming environment, we as
|
6
|
+
contributors and maintainers pledge to making participation in our project and
|
7
|
+
our community a harassment-free experience for everyone, regardless of age, body
|
8
|
+
size, disability, ethnicity, gender identity and expression, level of experience,
|
9
|
+
nationality, personal appearance, race, religion, or sexual identity and
|
10
|
+
orientation.
|
11
|
+
|
12
|
+
## Our Standards
|
13
|
+
|
14
|
+
Examples of behavior that contributes to creating a positive environment
|
15
|
+
include:
|
16
|
+
|
17
|
+
* Using welcoming and inclusive language
|
18
|
+
* Being respectful of differing viewpoints and experiences
|
19
|
+
* Gracefully accepting constructive criticism
|
20
|
+
* Focusing on what is best for the community
|
21
|
+
* Showing empathy towards other community members
|
22
|
+
|
23
|
+
Examples of unacceptable behavior by participants include:
|
24
|
+
|
25
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or
|
26
|
+
advances
|
27
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
28
|
+
* Public or private harassment
|
29
|
+
* Publishing others' private information, such as a physical or electronic
|
30
|
+
address, without explicit permission
|
31
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
32
|
+
professional setting
|
33
|
+
|
34
|
+
## Our Responsibilities
|
35
|
+
|
36
|
+
Project maintainers are responsible for clarifying the standards of acceptable
|
37
|
+
behavior and are expected to take appropriate and fair corrective action in
|
38
|
+
response to any instances of unacceptable behavior.
|
39
|
+
|
40
|
+
Project maintainers have the right and responsibility to remove, edit, or
|
41
|
+
reject comments, commits, code, wiki edits, issues, and other contributions
|
42
|
+
that are not aligned to this Code of Conduct, or to ban temporarily or
|
43
|
+
permanently any contributor for other behaviors that they deem inappropriate,
|
44
|
+
threatening, offensive, or harmful.
|
45
|
+
|
46
|
+
## Scope
|
47
|
+
|
48
|
+
This Code of Conduct applies both within project spaces and in public spaces
|
49
|
+
when an individual is representing the project or its community. Examples of
|
50
|
+
representing a project or community include using an official project e-mail
|
51
|
+
address, posting via an official social media account, or acting as an appointed
|
52
|
+
representative at an online or offline event. Representation of a project may be
|
53
|
+
further defined and clarified by project maintainers.
|
54
|
+
|
55
|
+
## Enforcement
|
56
|
+
|
57
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
58
|
+
reported by contacting the project team at mike.dalessio@gmail.com. All
|
59
|
+
complaints will be reviewed and investigated and will result in a response that
|
60
|
+
is deemed necessary and appropriate to the circumstances. The project team is
|
61
|
+
obligated to maintain confidentiality with regard to the reporter of an incident.
|
62
|
+
Further details of specific enforcement policies may be posted separately.
|
63
|
+
|
64
|
+
Project maintainers who do not follow or enforce the Code of Conduct in good
|
65
|
+
faith may face temporary or permanent repercussions as determined by other
|
66
|
+
members of the project's leadership.
|
67
|
+
|
68
|
+
## Attribution
|
69
|
+
|
70
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
71
|
+
available at [https://contributor-covenant.org/version/1/4][version]
|
72
|
+
|
73
|
+
[homepage]: https://contributor-covenant.org
|
74
|
+
[version]: https://contributor-covenant.org/version/1/4/
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 Mike Dalessio
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# Hoe::Markdown
|
2
|
+
|
3
|
+
Hoe::Markdown is a [Hoe](https://www.zenspider.com/projects/hoe.html) plugin to help manage your project's markdown files. It's intended for gem maintainers, but the underlying library of markdown manipulation methods might be generally useful.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
```ruby
|
11
|
+
gem 'hoe-markdown'
|
12
|
+
```
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle install
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install hoe-markdown
|
21
|
+
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
In your Rakefile:
|
26
|
+
|
27
|
+
``` ruby
|
28
|
+
Hoe::plugin :markdown
|
29
|
+
```
|
30
|
+
|
31
|
+
Rake tasks are exposed under the `markdown` namespace.
|
32
|
+
|
33
|
+
|
34
|
+
### Choosing your markdown files correctly
|
35
|
+
|
36
|
+
Hoe makes some outdated assumptions about the location of your README and your changelog files, which you (as a maintainer) need to opt out of. Specifically, you probably have something like this in your Rakefile
|
37
|
+
|
38
|
+
```
|
39
|
+
Hoe.spec "projectname" do
|
40
|
+
...
|
41
|
+
self.history_file = "CHANGELOG.md"
|
42
|
+
self.readme_file = "README.md"
|
43
|
+
...
|
44
|
+
end
|
45
|
+
```
|
46
|
+
|
47
|
+
If you've got files named "CHANGELOG.md" and/or "README.md" then this plugin will do the right thing, and you won't need to specify this in your Rakefile.
|
48
|
+
|
49
|
+
|
50
|
+
### Controlling what files are modified
|
51
|
+
|
52
|
+
By default, any `.md` file that Hoe knows about (through `Manifest.txt` or other attributes) will be included.
|
53
|
+
|
54
|
+
This can be overridden by setting the attribute named `markdown_linkify_files` which should be an array of file paths.
|
55
|
+
|
56
|
+
|
57
|
+
### Rake Tasks
|
58
|
+
|
59
|
+
An idempotent rake task `markdown:linkify` is created which will iterate through each of the markdown files in your project, and create hyperlinks for:
|
60
|
+
|
61
|
+
* any github username [formatted like `@username`]
|
62
|
+
* github issue mention [formatted like `#1234`]
|
63
|
+
* github issue URI [which must match either the Hoe metadata URI for the bug tracker, or that same URI's equivalent pull request URI]
|
64
|
+
|
65
|
+
So, for example, this text:
|
66
|
+
|
67
|
+
```markdown
|
68
|
+
# Changelog
|
69
|
+
|
70
|
+
## v1.0.0
|
71
|
+
|
72
|
+
Bugfix: Frobnicate the transmogrifier. #123
|
73
|
+
Thanks, @hobbes!
|
74
|
+
|
75
|
+
Feature: Finagle the sprocket. See https://github.com/cogswellcogs/sprocketkiller/issues/456
|
76
|
+
```
|
77
|
+
|
78
|
+
would be turned into:
|
79
|
+
|
80
|
+
```markdown
|
81
|
+
# Changelog
|
82
|
+
|
83
|
+
## v1.0.0
|
84
|
+
|
85
|
+
Bugfix: Frobnicate the transmogrifier. [#123](https://github.com/cogswellcogs/sprocketkiller/issues/123)
|
86
|
+
Thanks, [@hobbes](https://github.com/hobbes)!
|
87
|
+
|
88
|
+
Feature: Finagle the sprocket. See [#456](https://github.com/cogswellcogs/sprocketkiller/issues/456)
|
89
|
+
```
|
90
|
+
|
91
|
+
## Contributing
|
92
|
+
|
93
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/flavorjones/hoe-markdown. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/flavorjones/hoe-markdown/blob/master/CODE_OF_CONDUCT.md).
|
94
|
+
|
95
|
+
|
96
|
+
## License
|
97
|
+
|
98
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). See [LICENSE.txt](https://github.com/flavorjones/hoe-markdown/blob/master/LICENSE.txt).
|
99
|
+
|
100
|
+
|
101
|
+
## Code of Conduct
|
102
|
+
|
103
|
+
Everyone interacting in the Hoe::Markdown project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/flavorjones/hoe-markdown/blob/master/CODE_OF_CONDUCT.md).
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require_relative "lib/hoe/markdown/version"
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "hoe-markdown"
|
5
|
+
spec.version = Hoe::Markdown::VERSION
|
6
|
+
spec.authors = ["Mike Dalessio"]
|
7
|
+
spec.email = ["mike.dalessio@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{Hoe plugin with helpers for markdown documentation files.}
|
10
|
+
spec.description = %q{Hoe plugin with markdown helpers, for example to hyperlink github issues and github usernames in markdown files.}
|
11
|
+
spec.homepage = "https://github.com/flavorjones/hoe-markdown"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
16
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
17
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/master/CHANGELOG.md"
|
18
|
+
|
19
|
+
# Specify which files should be added to the gem when it is released.
|
20
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
21
|
+
spec.files = Dir.chdir(File.expand_path("..", __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.require_paths = ["lib"]
|
25
|
+
end
|
data/lib/hoe/markdown.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
class Hoe
|
2
|
+
module Markdown
|
3
|
+
#
|
4
|
+
# Optional: used to specify which markdown files to linkify. [default: any markdown files found in `files`].
|
5
|
+
#
|
6
|
+
attr_accessor :markdown_linkify_files
|
7
|
+
|
8
|
+
def default_markdown_linkify_files
|
9
|
+
spec.files.grep(/\.md$/)
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize_markdown
|
13
|
+
@markdown_linkify_files = nil
|
14
|
+
|
15
|
+
if File.exist?("CHANGELOG.md")
|
16
|
+
self.history_file = "CHANGELOG.md"
|
17
|
+
end
|
18
|
+
|
19
|
+
if File.exist?("README.md")
|
20
|
+
self.readme_file = "README.md"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def define_markdown_tasks
|
25
|
+
@markdown_linkify_files ||= default_markdown_linkify_files
|
26
|
+
return if markdown_linkify_files.empty?
|
27
|
+
|
28
|
+
namespace_name = "markdown:linkify"
|
29
|
+
linkify_tasks = []
|
30
|
+
|
31
|
+
namespace namespace_name do
|
32
|
+
markdown_linkify_files.each do |mdfile_path|
|
33
|
+
mdfile_name = File.basename(mdfile_path)
|
34
|
+
task_name = mdfile_name.downcase.split(".")[0..-2].join(".")
|
35
|
+
|
36
|
+
desc "hyperlink github issues and usernames in #{mdfile_name}"
|
37
|
+
task task_name do
|
38
|
+
puts "linkifying #{mdfile_path} ..."
|
39
|
+
markdown = File.read(mdfile_path)
|
40
|
+
|
41
|
+
markdown = Hoe::Markdown::Util.linkify_github_usernames(markdown)
|
42
|
+
if spec.metadata["bug_tracker_uri"]
|
43
|
+
markdown = Hoe::Markdown::Util.linkify_github_issues(markdown, spec.metadata["bug_tracker_uri"])
|
44
|
+
else
|
45
|
+
warn "Spec metadata URI for 'bugs' is missing, skipping linkification of issues and pull requests"
|
46
|
+
end
|
47
|
+
|
48
|
+
File.open(mdfile_path, "w") { |f| f.write markdown }
|
49
|
+
end
|
50
|
+
linkify_tasks << "#{namespace_name}:#{task_name}"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "hyperlink github issues and usernames in markdown files"
|
55
|
+
task namespace_name => linkify_tasks
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
require "hoe/markdown/version"
|
61
|
+
require "hoe/markdown/util"
|
@@ -0,0 +1,64 @@
|
|
1
|
+
class Hoe
|
2
|
+
module Markdown
|
3
|
+
module Util
|
4
|
+
GITHUB_ISSUE_MENTION_REGEX = %r{
|
5
|
+
# issue number, like '#1234'
|
6
|
+
\#([[:digit:]]+)
|
7
|
+
|
8
|
+
# not already in a markdown hyperlink
|
9
|
+
(?!\][\(\[])
|
10
|
+
|
11
|
+
# don't truncate the issue number to meet the previous negative lookahead
|
12
|
+
(?![[[:digit:]]])
|
13
|
+
}x
|
14
|
+
|
15
|
+
# see https://github.com/shinnn/github-username-regex
|
16
|
+
GITHUB_USER_REGEX = %r{
|
17
|
+
# username, like "@flavorjones"
|
18
|
+
@([[:alnum:]](?:[[:alnum:]]|-(?=[[:alnum:]])){0,38})
|
19
|
+
|
20
|
+
# not already in a markdown hyperlink
|
21
|
+
(?!\][\(\[])
|
22
|
+
|
23
|
+
# don't truncate the username to meet the previous negative lookahead
|
24
|
+
(?![[[:alnum:]]])
|
25
|
+
}x
|
26
|
+
|
27
|
+
def self.linkify_github_issues(markdown, issues_uri)
|
28
|
+
if issues_uri.nil? || issues_uri.empty?
|
29
|
+
raise "#{__FILE__}:#{__method__}: URI for bugs cannot be empty\n"
|
30
|
+
end
|
31
|
+
|
32
|
+
issue_uri_regex = %r{
|
33
|
+
# not already in a markdown hyperlink
|
34
|
+
(?<!\]\()
|
35
|
+
|
36
|
+
#{issues_uri}/([[:digit:]]+)
|
37
|
+
|
38
|
+
# don't truncate the issue number to meet the previous negative lookahead
|
39
|
+
(?![[[:digit:]]])
|
40
|
+
}x
|
41
|
+
|
42
|
+
pull_uri = issues_uri.gsub("issues", "pull")
|
43
|
+
pull_uri_regex = %r{
|
44
|
+
# not already in a markdown hyperlink
|
45
|
+
(?<!\]\()
|
46
|
+
|
47
|
+
#{pull_uri}/([[:digit:]]+)
|
48
|
+
|
49
|
+
# don't truncate the issue number to meet the previous negative lookahead
|
50
|
+
(?![[[:digit:]]])
|
51
|
+
}x
|
52
|
+
|
53
|
+
markdown
|
54
|
+
.gsub(GITHUB_ISSUE_MENTION_REGEX, "[#\\1](#{issues_uri}/\\1)")
|
55
|
+
.gsub(issue_uri_regex, "[#\\1](#{issues_uri}/\\1)")
|
56
|
+
.gsub(pull_uri_regex, "[#\\1](#{pull_uri}/\\1)")
|
57
|
+
end
|
58
|
+
|
59
|
+
def self.linkify_github_usernames(markdown)
|
60
|
+
markdown.gsub(GITHUB_USER_REGEX, "[@\\1](https://github.com/\\1)")
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
metadata
ADDED
@@ -0,0 +1,60 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: hoe-markdown
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Mike Dalessio
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-06-07 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Hoe plugin with markdown helpers, for example to hyperlink github issues
|
14
|
+
and github usernames in markdown files.
|
15
|
+
email:
|
16
|
+
- mike.dalessio@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".travis.yml"
|
24
|
+
- CHANGELOG.md
|
25
|
+
- CODE_OF_CONDUCT.md
|
26
|
+
- Gemfile
|
27
|
+
- LICENSE.txt
|
28
|
+
- README.md
|
29
|
+
- Rakefile
|
30
|
+
- hoe-markdown.gemspec
|
31
|
+
- lib/hoe/markdown.rb
|
32
|
+
- lib/hoe/markdown/util.rb
|
33
|
+
- lib/hoe/markdown/version.rb
|
34
|
+
homepage: https://github.com/flavorjones/hoe-markdown
|
35
|
+
licenses:
|
36
|
+
- MIT
|
37
|
+
metadata:
|
38
|
+
homepage_uri: https://github.com/flavorjones/hoe-markdown
|
39
|
+
source_code_uri: https://github.com/flavorjones/hoe-markdown
|
40
|
+
changelog_uri: https://github.com/flavorjones/hoe-markdown/blob/master/CHANGELOG.md
|
41
|
+
post_install_message:
|
42
|
+
rdoc_options: []
|
43
|
+
require_paths:
|
44
|
+
- lib
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: 2.3.0
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
requirements: []
|
56
|
+
rubygems_version: 3.1.2
|
57
|
+
signing_key:
|
58
|
+
specification_version: 4
|
59
|
+
summary: Hoe plugin with helpers for markdown documentation files.
|
60
|
+
test_files: []
|