doc_health 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.rubocop.yml +14 -0
- data/README.md +68 -0
- data/Rakefile +17 -0
- data/exe/doc-health +6 -0
- data/lib/doc_health/cli.rb +29 -0
- data/lib/doc_health/git.rb +37 -0
- data/lib/doc_health/report.rb +45 -0
- data/lib/doc_health/version.rb +5 -0
- data/lib/doc_health.rb +14 -0
- data/sig/doc_health.rbs +4 -0
- metadata +96 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: bc458994be6f5809ab84f50071a9bbe9996bf7ef5976681d84df0d9670c08ade
|
|
4
|
+
data.tar.gz: 0f367d8e57de1f2f759be7dffe973308ee0aaf9bdfc09c585fda33ddb57212de
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 3d9df3626c0c98ac8351b1cdbfe93bd9aebf39de2d37065686456dbb8955b7dd8273174a24eaf07a51aa5f2bb0fd27fe5e603426df13aa91f8c4104978f16411
|
|
7
|
+
data.tar.gz: ba46718bf0a723badcbf2cde716aa19cc5cc61cee6c91c15f9290ed029f143202794b72e71659ee9d078b10c0e45a5e0873033f359b8f293a0086ab5e99eebc3
|
data/.rubocop.yml
ADDED
data/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# DocHealth
|
|
2
|
+
|
|
3
|
+
DocHealth is a Ruby gem that scans a given path for Markdown (`.md`) files and retrieves the last updated date and author. It provides a terminal readout or exports the results to a CSV file, helping you monitor the health of your documentation.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Install the gem and add it to your application's Gemfile by executing:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
bundle add doc_health
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
If bundler is not being used to manage dependencies, install the gem manually:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
gem install doc_health
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Usage
|
|
20
|
+
|
|
21
|
+
To scan a directory for Markdown files and display the last modified date and author, run:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
doc-health --path /path/to/docs
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
To output the results to a CSV file:
|
|
28
|
+
|
|
29
|
+
```bash
|
|
30
|
+
doc-health --path /path/to/docs --csv
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Development
|
|
34
|
+
|
|
35
|
+
After cloning the repository, install dependencies:
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
bin/setup
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Run the tests:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
rake test
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Use `bin/console` for an interactive prompt to experiment with the code.
|
|
48
|
+
|
|
49
|
+
To install this gem locally:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
bundle exec rake install
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
To release a new version:
|
|
56
|
+
1. Update the version number in `lib/doc_health/version.rb`.
|
|
57
|
+
2. Run:
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
bundle exec rake release
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
This will create a git tag, push commits and the tag, and publish the gem to [RubyGems](https://rubygems.org).
|
|
64
|
+
|
|
65
|
+
## Contributing
|
|
66
|
+
|
|
67
|
+
Bug reports and pull requests are welcome on GitHub at [https://github.com/YOUR_USERNAME/doc_health](https://github.com/YOUR_USERNAME/doc_health).
|
|
68
|
+
|
data/Rakefile
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "bundler/gem_tasks"
|
|
4
|
+
require "minitest/test_task"
|
|
5
|
+
|
|
6
|
+
Minitest::TestTask.create
|
|
7
|
+
|
|
8
|
+
require "rubocop/rake_task"
|
|
9
|
+
|
|
10
|
+
RuboCop::RakeTask.new
|
|
11
|
+
|
|
12
|
+
task default: %i[test rubocop]
|
|
13
|
+
|
|
14
|
+
task :build_and_install do
|
|
15
|
+
system "gem build doc_health.gemspec"
|
|
16
|
+
system "gem install doc_health-0.1.0.gem"
|
|
17
|
+
end
|
data/exe/doc-health
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "optparse"
|
|
4
|
+
|
|
5
|
+
module DocHealth
|
|
6
|
+
class CLI
|
|
7
|
+
def self.options
|
|
8
|
+
options = {}
|
|
9
|
+
|
|
10
|
+
OptionParser.new do |opts|
|
|
11
|
+
opts.banner = "Usage: doc-health [options]"
|
|
12
|
+
|
|
13
|
+
opts.on("-h", "--help", "Show this help message") do
|
|
14
|
+
exit
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
opts.on("-p PATH", "--path=PATH", "Specify the documentation path") do |path|
|
|
18
|
+
options[:path] = path
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
opts.on("-csv", "--csv", "Generate CSV report") do
|
|
22
|
+
options[:csv] = true
|
|
23
|
+
end
|
|
24
|
+
end.parse!
|
|
25
|
+
|
|
26
|
+
options
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "git"
|
|
4
|
+
|
|
5
|
+
module DocHealth
|
|
6
|
+
class Git
|
|
7
|
+
attr_reader :path
|
|
8
|
+
|
|
9
|
+
def initialize(path)
|
|
10
|
+
@git = ::Git.open(path)
|
|
11
|
+
@path = path
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def file_commit_author
|
|
15
|
+
Dir.glob("#{path}**/*.md").map do |file|
|
|
16
|
+
est_time = last_commit_date(file)
|
|
17
|
+
author = last_commit_author(file)
|
|
18
|
+
[file, est_time, author]
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def last_commit_date(file)
|
|
23
|
+
# handle new files not in the git history
|
|
24
|
+
gitlog = @git.log(1).object(file).first
|
|
25
|
+
return "N/A" unless gitlog
|
|
26
|
+
|
|
27
|
+
gitlog.date.getlocal("-05:00").strftime("%Y-%m-%d %I:%M %p")
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def last_commit_author(file)
|
|
31
|
+
gitlog = @git.log(1).object(file).first
|
|
32
|
+
return "N/A" unless gitlog
|
|
33
|
+
|
|
34
|
+
@git.log(1).object(file).first.author.name
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "terminal-table"
|
|
4
|
+
require "csv"
|
|
5
|
+
require_relative "git"
|
|
6
|
+
|
|
7
|
+
module DocHealth
|
|
8
|
+
class Report
|
|
9
|
+
attr_reader :path
|
|
10
|
+
|
|
11
|
+
def initialize(options)
|
|
12
|
+
@path = options[:path] || Dir.pwd
|
|
13
|
+
@generate_csv = options[:csv] || false
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def generate
|
|
17
|
+
unless File.directory?(path)
|
|
18
|
+
puts "The path is invalid."
|
|
19
|
+
return
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
rows = Git.new(path).file_commit_author
|
|
23
|
+
|
|
24
|
+
if @generate_csv
|
|
25
|
+
generate_csv(rows)
|
|
26
|
+
puts "📋 CSV generated"
|
|
27
|
+
return
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
print_table(["File", "Last Commit (EST)"], rows)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def print_table(headers, rows)
|
|
34
|
+
table = Terminal::Table.new headings: headers, rows: rows
|
|
35
|
+
puts table
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def generate_csv(rows)
|
|
39
|
+
CSV.open("doc_health_report.csv", "wb") do |csv|
|
|
40
|
+
csv << ["File", "Last Commit (EST)"]
|
|
41
|
+
rows.each { |row| csv << row }
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
data/lib/doc_health.rb
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "doc_health/version"
|
|
4
|
+
require_relative "doc_health/cli"
|
|
5
|
+
require_relative "doc_health/report"
|
|
6
|
+
|
|
7
|
+
module DocHealth
|
|
8
|
+
class Error < StandardError; end
|
|
9
|
+
|
|
10
|
+
def self.health_report
|
|
11
|
+
options = DocHealth::CLI.options
|
|
12
|
+
Report.new(options).generate
|
|
13
|
+
end
|
|
14
|
+
end
|
data/sig/doc_health.rbs
ADDED
metadata
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: doc_health
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Greg Dodd
|
|
8
|
+
bindir: exe
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 2025-02-06 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: csv
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: git
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - "~>"
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '2.3'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - "~>"
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '2.3'
|
|
40
|
+
- !ruby/object:Gem::Dependency
|
|
41
|
+
name: terminal-table
|
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
|
43
|
+
requirements:
|
|
44
|
+
- - "~>"
|
|
45
|
+
- !ruby/object:Gem::Version
|
|
46
|
+
version: '4.0'
|
|
47
|
+
type: :runtime
|
|
48
|
+
prerelease: false
|
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '4.0'
|
|
54
|
+
description: Returns a report on the health of your markdown documentation. The generated
|
|
55
|
+
report is a CSV.
|
|
56
|
+
email:
|
|
57
|
+
- greg.dodd@shopify.com
|
|
58
|
+
executables:
|
|
59
|
+
- doc-health
|
|
60
|
+
extensions: []
|
|
61
|
+
extra_rdoc_files: []
|
|
62
|
+
files:
|
|
63
|
+
- ".rubocop.yml"
|
|
64
|
+
- README.md
|
|
65
|
+
- Rakefile
|
|
66
|
+
- exe/doc-health
|
|
67
|
+
- lib/doc_health.rb
|
|
68
|
+
- lib/doc_health/cli.rb
|
|
69
|
+
- lib/doc_health/git.rb
|
|
70
|
+
- lib/doc_health/report.rb
|
|
71
|
+
- lib/doc_health/version.rb
|
|
72
|
+
- sig/doc_health.rbs
|
|
73
|
+
homepage: https://github.com/gregdodd/doc-health.git
|
|
74
|
+
licenses: []
|
|
75
|
+
metadata:
|
|
76
|
+
homepage_uri: https://github.com/gregdodd/doc-health.git
|
|
77
|
+
source_code_uri: https://github.com/gregdodd/doc-health.git
|
|
78
|
+
changelog_uri: https://github.com/gregdodd/doc-health/blob/main/README.md
|
|
79
|
+
rdoc_options: []
|
|
80
|
+
require_paths:
|
|
81
|
+
- lib
|
|
82
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
|
+
requirements:
|
|
84
|
+
- - ">="
|
|
85
|
+
- !ruby/object:Gem::Version
|
|
86
|
+
version: 3.1.0
|
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
|
+
requirements:
|
|
89
|
+
- - ">="
|
|
90
|
+
- !ruby/object:Gem::Version
|
|
91
|
+
version: '0'
|
|
92
|
+
requirements: []
|
|
93
|
+
rubygems_version: 3.6.3
|
|
94
|
+
specification_version: 4
|
|
95
|
+
summary: Returns a report on the health of your markdown documentation.
|
|
96
|
+
test_files: []
|