dim_to_rst 2.0.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/CHANGELOG.md +29 -0
- data/README.md +32 -0
- data/dim_to_rst.gemspec +36 -0
- data/exe/dim_to_rst +91 -0
- data/lib/dim_to_rst/templates/index.rst.erb +16 -0
- data/lib/dim_to_rst/templates/module.rst.erb +20 -0
- data/lib/dim_to_rst/version.rb +5 -0
- data/lib/dim_to_rst.rb +5 -0
- metadata +82 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 579d2781264a9f8d98969971456201971ad74b116bbaf708fa7978040e525b5c
|
4
|
+
data.tar.gz: '09189a0087c0028f24b5de95ce110cb478f0ed45b98f334d8306bd13307fb578'
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 867bc94e7ed751a09450976883689ad214e521d22cfc66e49d048ad07e0e9f3249d5b32f60c401473413b2be7bd8a554a350f3d982edc5c21d69dc3c0261fe94
|
7
|
+
data.tar.gz: c2f5bbd3fe751b1002325afa0132347499f01f826d173b25316a1a50c41a09605cf7aa6393bf72f765b5b8ab4e7225cdf07f10e5f5a92c83cbd08042f385d0bc
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
## [2.0.0] - 2024-11-27
|
11
|
+
|
12
|
+
### Changed
|
13
|
+
- ! Adapted the code for `dim-toolkit` `>= 2.1.1`
|
14
|
+
|
15
|
+
## [1.0.1] - 2023-10-06
|
16
|
+
|
17
|
+
### Fixed
|
18
|
+
- Fixed a `NoMethodError` that was introduced with `activesupport 7.1.0`.
|
19
|
+
|
20
|
+
## [1.0.0] - 2023-05-15
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
- ! Update `activesupport` from `~> 6` to `~> 7`
|
24
|
+
|
25
|
+
## [0.1.0] - 2022-11-22
|
26
|
+
|
27
|
+
### Added
|
28
|
+
- Executable file and necessary templates to read the DIM requirements and
|
29
|
+
produce basic RST output.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Dim to RST
|
2
|
+
|
3
|
+
This example illustrates how to use [dim](https://github.com/esrlabs/dox/tree/master/dim)
|
4
|
+
inside a gem.
|
5
|
+
|
6
|
+
This example shows how to create a custom requirements exporter.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Install the gem and add to the application's Gemfile by executing:
|
11
|
+
|
12
|
+
$ bundle add dim_to_rst
|
13
|
+
|
14
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
15
|
+
|
16
|
+
$ gem install dim_to_rst
|
17
|
+
|
18
|
+
## Usage
|
19
|
+
|
20
|
+
$ dim_to_rst <path/to/config.yaml> <export/destination>
|
21
|
+
|
22
|
+
## Development
|
23
|
+
|
24
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run
|
25
|
+
`rake spec` to run the tests.
|
26
|
+
|
27
|
+
To install this gem onto your local machine, run `bundle exec rake install`.
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
Bug reports and pull requests are welcome on GitHub at
|
32
|
+
[https://github.com/esrlabs/dox/tree/master/dim/examples/scripting/dim_to_rst].
|
data/dim_to_rst.gemspec
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/dim_to_rst/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "dim_to_rst"
|
7
|
+
spec.version = DimToRst::VERSION
|
8
|
+
spec.authors = ["Accenture"]
|
9
|
+
|
10
|
+
spec.summary = "An example of a custom exporter gem for dim."
|
11
|
+
spec.description = "Exports requirements written in dim to plain RST source."
|
12
|
+
spec.homepage = "https://github.com/esrlabs/dox/tree/master/dim/examples/scripting/dim_to_rst"
|
13
|
+
spec.required_ruby_version = ">= 2.7"
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = "https://github.com/esrlabs/dox/tree/master/dim/examples/scripting/dim_to_rst/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(__dir__) do
|
24
|
+
`git ls-files -z`.split("\x0").select do |f|
|
25
|
+
(File.expand_path(f) == __FILE__) ||
|
26
|
+
f.start_with?(*%w[exe/ lib/ CHANGELOG.md README.md])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
spec.bindir = "exe"
|
31
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
+
spec.require_paths = ["lib"]
|
33
|
+
|
34
|
+
spec.add_dependency "activesupport", "~> 7"
|
35
|
+
spec.add_dependency "dim-toolkit", '>= 2.1.1'
|
36
|
+
end
|
data/exe/dim_to_rst
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "active_support"
|
5
|
+
require "active_support/core_ext/string"
|
6
|
+
require "dim/loader"
|
7
|
+
require "erb"
|
8
|
+
require "fileutils"
|
9
|
+
|
10
|
+
# rubocop:disable Style/GlobalVars
|
11
|
+
# (required by DIM)
|
12
|
+
$subcommands = {}
|
13
|
+
# rubocop:enable Style/GlobalVars
|
14
|
+
|
15
|
+
def asil_level(requirement)
|
16
|
+
requirement.asil == "not_set" ? nil : "#{requirement.asil} |"
|
17
|
+
end
|
18
|
+
|
19
|
+
def req_text(requirement)
|
20
|
+
buffer = StringIO.new
|
21
|
+
text_lines = requirement.text.lines.map(&:chomp)
|
22
|
+
buffer << text_lines.shift
|
23
|
+
|
24
|
+
if text_lines.any?
|
25
|
+
text_lines.each do |line|
|
26
|
+
buffer << "\n#{line.indent(7)}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
buffer.string
|
31
|
+
end
|
32
|
+
|
33
|
+
def req_refs(references)
|
34
|
+
return "none" unless references&.any?
|
35
|
+
|
36
|
+
references.map { |ref| ":ref:`dim-req-#{ref}`" }.join(', ')
|
37
|
+
end
|
38
|
+
|
39
|
+
input_file = ARGV.shift
|
40
|
+
output_dir = ARGV.shift
|
41
|
+
|
42
|
+
@loader = Dim::Loader.new.tap do |loader|
|
43
|
+
loader.load input_filenames: [input_file]
|
44
|
+
end
|
45
|
+
|
46
|
+
categories = {}
|
47
|
+
|
48
|
+
@loader.requirements.each_value do |requirement|
|
49
|
+
category_name = requirement.category
|
50
|
+
|
51
|
+
category_data = categories[category_name] ||= {}
|
52
|
+
category_data[:name] = category_name
|
53
|
+
category_data[:id] = category_name.parameterize.downcase
|
54
|
+
category_requirements = category_data[:requirements] ||= []
|
55
|
+
category_requirements << requirement
|
56
|
+
|
57
|
+
module_name = requirement.moduleName
|
58
|
+
category_modules = category_data[:modules] ||= {}
|
59
|
+
module_data = category_modules[module_name] ||= {}
|
60
|
+
module_data[:name] = module_name
|
61
|
+
module_data[:id] = module_name.parameterize.downcase
|
62
|
+
module_requirements = module_data[:requirements] ||= []
|
63
|
+
module_requirements << requirement
|
64
|
+
end
|
65
|
+
|
66
|
+
templates_path = Pathname.new(__dir__) / ".." / "lib" / "dim_to_rst" / "templates"
|
67
|
+
|
68
|
+
index_template = File.read(templates_path / "index.rst.erb")
|
69
|
+
index_erb = ERB.new(index_template)
|
70
|
+
index_dest = File.join(output_dir, "index.rst")
|
71
|
+
|
72
|
+
File.write(index_dest, index_erb.result_with_hash(
|
73
|
+
categories: categories
|
74
|
+
))
|
75
|
+
|
76
|
+
module_template = File.read(templates_path / "module.rst.erb")
|
77
|
+
module_erb = ERB.new(module_template)
|
78
|
+
|
79
|
+
categories.each do |category_name, category_data|
|
80
|
+
category_dir = File.join(output_dir, category_data[:id])
|
81
|
+
|
82
|
+
FileUtils.rm_rf(category_dir)
|
83
|
+
FileUtils.mkdir(category_dir)
|
84
|
+
|
85
|
+
category_data[:modules].each do |module_name, module_data|
|
86
|
+
module_dest = File.join(category_dir, "#{module_data[:id]}.rst")
|
87
|
+
File.write(module_dest, module_erb.result_with_hash(
|
88
|
+
module_name: module_name, module_data: module_data
|
89
|
+
))
|
90
|
+
end
|
91
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Requirements
|
2
|
+
============
|
3
|
+
|
4
|
+
<% categories.each do |category_name, category_data| %>
|
5
|
+
<% label = category_name.capitalize %>
|
6
|
+
|
7
|
+
<%= label %>
|
8
|
+
<%= '-' * label.length %>
|
9
|
+
|
10
|
+
.. toctree::
|
11
|
+
:maxdepth: 1
|
12
|
+
:glob:
|
13
|
+
|
14
|
+
<%= category_data[:id] %>/*
|
15
|
+
|
16
|
+
<% end %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<%= module_name %>
|
2
|
+
<%= '=' * module_name.length %>
|
3
|
+
|
4
|
+
<% module_data[:requirements].each do |requirement|
|
5
|
+
requirement_id = requirement.id %>
|
6
|
+
|
7
|
+
.. _`dim-req-<%= requirement_id %>`:
|
8
|
+
|
9
|
+
<%= requirement_id %>
|
10
|
+
<%= "-" * requirement_id.length %>
|
11
|
+
|
12
|
+
.. list-table::
|
13
|
+
|
14
|
+
* - **<%= requirement_id %>** | <%= requirement.accepted %> | <%= asil_level(requirement) %> <%= requirement.origin %>
|
15
|
+
* - **Tags:** <%= requirement.tags %>
|
16
|
+
* - **Test Setups:** <%= requirement.test_setups %>
|
17
|
+
* - <%= req_text(requirement) %>
|
18
|
+
* - **References:** <%= req_refs(requirement.refs) %>
|
19
|
+
* - **Back References:** <%= req_refs(requirement.backwardRefs) %>
|
20
|
+
<% end %>
|
data/lib/dim_to_rst.rb
ADDED
metadata
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dim_to_rst
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Accenture
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2025-01-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: dim-toolkit
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.1
|
41
|
+
description: Exports requirements written in dim to plain RST source.
|
42
|
+
email:
|
43
|
+
executables:
|
44
|
+
- dim_to_rst
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- README.md
|
50
|
+
- dim_to_rst.gemspec
|
51
|
+
- exe/dim_to_rst
|
52
|
+
- lib/dim_to_rst.rb
|
53
|
+
- lib/dim_to_rst/templates/index.rst.erb
|
54
|
+
- lib/dim_to_rst/templates/module.rst.erb
|
55
|
+
- lib/dim_to_rst/version.rb
|
56
|
+
homepage: https://github.com/esrlabs/dox/tree/master/dim/examples/scripting/dim_to_rst
|
57
|
+
licenses: []
|
58
|
+
metadata:
|
59
|
+
allowed_push_host: https://rubygems.org
|
60
|
+
homepage_uri: https://github.com/esrlabs/dox/tree/master/dim/examples/scripting/dim_to_rst
|
61
|
+
source_code_uri: https://github.com/esrlabs/dox/tree/master/dim/examples/scripting/dim_to_rst
|
62
|
+
changelog_uri: https://github.com/esrlabs/dox/tree/master/dim/examples/scripting/dim_to_rst/CHANGELOG.md
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '2.7'
|
72
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - ">="
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
requirements: []
|
78
|
+
rubygems_version: 3.1.6
|
79
|
+
signing_key:
|
80
|
+
specification_version: 4
|
81
|
+
summary: An example of a custom exporter gem for dim.
|
82
|
+
test_files: []
|