mandoc 0.0.1
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 +7 -0
- data/COPYING +674 -0
- data/README.md +117 -0
- data/ext/mandoc/extconf.rb +59 -0
- data/ext/mandoc/rb_mandoc.c +548 -0
- data/ext/mandoc/rb_mandoc.h +22 -0
- data/lib/mandoc/version.rb +19 -0
- data/lib/mandoc.rb +26 -0
- data/mandoc-1.14.6/LICENSE +55 -0
- data/mandoc-1.14.6/arch.c +54 -0
- data/mandoc-1.14.6/att.c +49 -0
- data/mandoc-1.14.6/catman.c +260 -0
- data/mandoc-1.14.6/cgi.c +1279 -0
- data/mandoc-1.14.6/chars.c +507 -0
- data/mandoc-1.14.6/compat_err.c +103 -0
- data/mandoc-1.14.6/compat_fts.c +696 -0
- data/mandoc-1.14.6/compat_fts.h +106 -0
- data/mandoc-1.14.6/compat_getline.c +59 -0
- data/mandoc-1.14.6/compat_getsubopt.c +87 -0
- data/mandoc-1.14.6/compat_isblank.c +23 -0
- data/mandoc-1.14.6/compat_mkdtemp.c +50 -0
- data/mandoc-1.14.6/compat_mkstemps.c +63 -0
- data/mandoc-1.14.6/compat_ohash.c +330 -0
- data/mandoc-1.14.6/compat_ohash.h +72 -0
- data/mandoc-1.14.6/compat_progname.c +31 -0
- data/mandoc-1.14.6/compat_reallocarray.c +40 -0
- data/mandoc-1.14.6/compat_recallocarray.c +99 -0
- data/mandoc-1.14.6/compat_strcasestr.c +64 -0
- data/mandoc-1.14.6/compat_stringlist.c +135 -0
- data/mandoc-1.14.6/compat_stringlist.h +48 -0
- data/mandoc-1.14.6/compat_strlcat.c +57 -0
- data/mandoc-1.14.6/compat_strlcpy.c +52 -0
- data/mandoc-1.14.6/compat_strndup.c +42 -0
- data/mandoc-1.14.6/compat_strsep.c +70 -0
- data/mandoc-1.14.6/compat_strtonum.c +67 -0
- data/mandoc-1.14.6/compat_vasprintf.c +47 -0
- data/mandoc-1.14.6/config.h +52 -0
- data/mandoc-1.14.6/dba.c +508 -0
- data/mandoc-1.14.6/dba.h +50 -0
- data/mandoc-1.14.6/dba_array.c +190 -0
- data/mandoc-1.14.6/dba_array.h +47 -0
- data/mandoc-1.14.6/dba_read.c +74 -0
- data/mandoc-1.14.6/dba_write.c +127 -0
- data/mandoc-1.14.6/dba_write.h +30 -0
- data/mandoc-1.14.6/dbm.c +480 -0
- data/mandoc-1.14.6/dbm.h +68 -0
- data/mandoc-1.14.6/dbm_map.c +194 -0
- data/mandoc-1.14.6/dbm_map.h +29 -0
- data/mandoc-1.14.6/demandoc.c +260 -0
- data/mandoc-1.14.6/eqn.c +1132 -0
- data/mandoc-1.14.6/eqn.h +72 -0
- data/mandoc-1.14.6/eqn_html.c +246 -0
- data/mandoc-1.14.6/eqn_parse.h +48 -0
- data/mandoc-1.14.6/eqn_term.c +174 -0
- data/mandoc-1.14.6/html.c +1102 -0
- data/mandoc-1.14.6/html.h +142 -0
- data/mandoc-1.14.6/lib.c +35 -0
- data/mandoc-1.14.6/libman.h +42 -0
- data/mandoc-1.14.6/libmandoc.h +85 -0
- data/mandoc-1.14.6/libmdoc.h +87 -0
- data/mandoc-1.14.6/main.c +1375 -0
- data/mandoc-1.14.6/main.h +53 -0
- data/mandoc-1.14.6/man.c +345 -0
- data/mandoc-1.14.6/man.h +21 -0
- data/mandoc-1.14.6/man_html.c +640 -0
- data/mandoc-1.14.6/man_macro.c +470 -0
- data/mandoc-1.14.6/man_term.c +1143 -0
- data/mandoc-1.14.6/man_validate.c +660 -0
- data/mandoc-1.14.6/manconf.h +58 -0
- data/mandoc-1.14.6/mandoc.c +669 -0
- data/mandoc-1.14.6/mandoc.h +329 -0
- data/mandoc-1.14.6/mandoc_aux.c +118 -0
- data/mandoc-1.14.6/mandoc_aux.h +27 -0
- data/mandoc-1.14.6/mandoc_msg.c +375 -0
- data/mandoc-1.14.6/mandoc_ohash.c +65 -0
- data/mandoc-1.14.6/mandoc_ohash.h +23 -0
- data/mandoc-1.14.6/mandoc_parse.h +44 -0
- data/mandoc-1.14.6/mandoc_xr.c +123 -0
- data/mandoc-1.14.6/mandoc_xr.h +31 -0
- data/mandoc-1.14.6/mandocd.c +282 -0
- data/mandoc-1.14.6/mandocdb.c +2448 -0
- data/mandoc-1.14.6/manpath.c +363 -0
- data/mandoc-1.14.6/mansearch.c +851 -0
- data/mandoc-1.14.6/mansearch.h +118 -0
- data/mandoc-1.14.6/mdoc.c +433 -0
- data/mandoc-1.14.6/mdoc.h +158 -0
- data/mandoc-1.14.6/mdoc_argv.c +682 -0
- data/mandoc-1.14.6/mdoc_html.c +1762 -0
- data/mandoc-1.14.6/mdoc_macro.c +1600 -0
- data/mandoc-1.14.6/mdoc_man.c +1850 -0
- data/mandoc-1.14.6/mdoc_markdown.c +1610 -0
- data/mandoc-1.14.6/mdoc_state.c +256 -0
- data/mandoc-1.14.6/mdoc_term.c +1964 -0
- data/mandoc-1.14.6/mdoc_validate.c +3062 -0
- data/mandoc-1.14.6/msec.c +37 -0
- data/mandoc-1.14.6/out.c +544 -0
- data/mandoc-1.14.6/out.h +70 -0
- data/mandoc-1.14.6/preconv.c +179 -0
- data/mandoc-1.14.6/read.c +732 -0
- data/mandoc-1.14.6/roff.c +4390 -0
- data/mandoc-1.14.6/roff.h +561 -0
- data/mandoc-1.14.6/roff_html.c +119 -0
- data/mandoc-1.14.6/roff_int.h +94 -0
- data/mandoc-1.14.6/roff_term.c +266 -0
- data/mandoc-1.14.6/roff_validate.c +151 -0
- data/mandoc-1.14.6/soelim.c +182 -0
- data/mandoc-1.14.6/st.c +82 -0
- data/mandoc-1.14.6/tag.c +327 -0
- data/mandoc-1.14.6/tag.h +35 -0
- data/mandoc-1.14.6/tbl.c +183 -0
- data/mandoc-1.14.6/tbl.h +121 -0
- data/mandoc-1.14.6/tbl_data.c +323 -0
- data/mandoc-1.14.6/tbl_html.c +293 -0
- data/mandoc-1.14.6/tbl_int.h +47 -0
- data/mandoc-1.14.6/tbl_layout.c +376 -0
- data/mandoc-1.14.6/tbl_opts.c +173 -0
- data/mandoc-1.14.6/tbl_parse.h +30 -0
- data/mandoc-1.14.6/tbl_term.c +948 -0
- data/mandoc-1.14.6/term.c +1113 -0
- data/mandoc-1.14.6/term.h +158 -0
- data/mandoc-1.14.6/term_ascii.c +424 -0
- data/mandoc-1.14.6/term_ps.c +1362 -0
- data/mandoc-1.14.6/term_tab.c +130 -0
- data/mandoc-1.14.6/term_tag.c +227 -0
- data/mandoc-1.14.6/term_tag.h +34 -0
- data/mandoc-1.14.6/tree.c +536 -0
- metadata +170 -0
data/README.md
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# mandoc for Ruby
|
|
2
|
+
|
|
3
|
+
This is a parser library for mdoc/man formats, which bases on roff
|
|
4
|
+
format. This is implemented as a [mandoc][m] binding for Ruby.
|
|
5
|
+
|
|
6
|
+
Please not that libmandoc interface is [*not* particularly
|
|
7
|
+
recommended][lm] officially. That said, as far as I consider, mandoc
|
|
8
|
+
is the best for this purpose.
|
|
9
|
+
|
|
10
|
+
Project links: [repository][cb], [mirror][gh]
|
|
11
|
+
|
|
12
|
+
[lm]: https://mandoc.bsd.lv/libmandoc.html
|
|
13
|
+
[cb]: https://codeberg.org/gemmaro/ruby-mandoc
|
|
14
|
+
[gh]: https://github.com/gemmaro/ruby-mandoc
|
|
15
|
+
[m]: https://mandoc.bsd.lv/
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
Install the gem and add to the application's `Gemfile` by executing:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
bundle add mandoc
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
gem install mandoc
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Usage
|
|
32
|
+
|
|
33
|
+
This gem can parse manpages in files and examine metadata, walk
|
|
34
|
+
abstract syntax tree (AST), and converts into some formats. Please
|
|
35
|
+
refer to the API document for details.
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
require "mandoc"
|
|
39
|
+
|
|
40
|
+
parser = Mandoc::Parser.new
|
|
41
|
+
|
|
42
|
+
# "meta" is something like "document".
|
|
43
|
+
meta = parser.parse_file(path_to_mandoc_1)
|
|
44
|
+
meta.section #=> "1"
|
|
45
|
+
meta.title #=> "MANDOC"
|
|
46
|
+
|
|
47
|
+
meta.markdown #=> rendered string in Markdown
|
|
48
|
+
|
|
49
|
+
# Walk AST
|
|
50
|
+
root = meta.first_node
|
|
51
|
+
root.first_child.next_sibling.name #=> "Dt"
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Development
|
|
55
|
+
|
|
56
|
+
First, you have to download mandoc sources. The `bin/download` script
|
|
57
|
+
downloads the tarball. Then extract into, e.g. `mandoc-1.14.6/`.
|
|
58
|
+
|
|
59
|
+
Then generate `config.h` file of mandoc. Please refer to
|
|
60
|
+
`bin/configure` script to do this.
|
|
61
|
+
|
|
62
|
+
Run `bin/setup` to install dependencies. Then, run `rake test` to run
|
|
63
|
+
the tests. You can also run `bin/console` for an interactive prompt
|
|
64
|
+
that will allow you to experiment.
|
|
65
|
+
|
|
66
|
+
To install this gem onto your local machine, run `bundle exec rake
|
|
67
|
+
install`. To release a new version, update the version number in
|
|
68
|
+
`version.rb`, and then run `bundle exec rake release`, which will
|
|
69
|
+
create a git tag for the version, push git commits and the created
|
|
70
|
+
tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
|
71
|
+
|
|
72
|
+
On OpenBSD, and if you are using packaged `ruby`, native compilation
|
|
73
|
+
can fail because `install` command has `-o root -g bin` flags. You
|
|
74
|
+
can overwrite the behavior; please refer to `bin/compile` script.
|
|
75
|
+
|
|
76
|
+
References: [my past project which uses similar mkmf strategy][re]
|
|
77
|
+
|
|
78
|
+
[re]: https://github.com/gemmaro/ruby-eldc
|
|
79
|
+
|
|
80
|
+
## Contributing
|
|
81
|
+
|
|
82
|
+
Bug reports and pull requests are welcome.
|
|
83
|
+
|
|
84
|
+
## Prior Works
|
|
85
|
+
|
|
86
|
+
There are few libraries which parses manpages in mdoc/man/roff
|
|
87
|
+
formats. [man\_parser][mp] gem is a very concise parser
|
|
88
|
+
implementation written in pure Ruby.
|
|
89
|
+
|
|
90
|
+
The ronn gem is for converting Markdown-like format into roff/HTML,
|
|
91
|
+
but not for parsing existing man pages. The md2man gem and the
|
|
92
|
+
kramdown-man also have a same idea.
|
|
93
|
+
|
|
94
|
+
[mp]: https://github.com/grosser/man_parser
|
|
95
|
+
|
|
96
|
+
## License
|
|
97
|
+
|
|
98
|
+
The gem archive contains some files from the mandoc sources, which is
|
|
99
|
+
distributed under the ISC license. Please refer to the
|
|
100
|
+
`mandoc-*.*.*/LICENSE` file in the archive.
|
|
101
|
+
|
|
102
|
+
This mandoc gem itself is distributed under the following license:
|
|
103
|
+
|
|
104
|
+
Copyright (C) 2026 gemmaro
|
|
105
|
+
|
|
106
|
+
This program is free software: you can redistribute it and/or modify
|
|
107
|
+
it under the terms of the GNU General Public License as published by
|
|
108
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
109
|
+
(at your option) any later version.
|
|
110
|
+
|
|
111
|
+
This program is distributed in the hope that it will be useful,
|
|
112
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
113
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
114
|
+
GNU General Public License for more details.
|
|
115
|
+
|
|
116
|
+
You should have received a copy of the GNU General Public License
|
|
117
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Copyright (C) 2026 gemmaro
|
|
4
|
+
#
|
|
5
|
+
# This program is free software: you can redistribute it and/or modify
|
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
# (at your option) any later version.
|
|
9
|
+
#
|
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
# GNU General Public License for more details.
|
|
14
|
+
|
|
15
|
+
require "mkmf"
|
|
16
|
+
|
|
17
|
+
# Suppress following:
|
|
18
|
+
#
|
|
19
|
+
# compiling ../../../../ext/mandoc/../../mandoc-1.14.6/mandoc.c
|
|
20
|
+
# [...]/mandoc.c:321:14: warning: implicit conversion loses
|
|
21
|
+
# integer precision: 'long' to 'int' [-Wshorten-64-to-32]
|
|
22
|
+
# 321 | *sz = *end - *start;
|
|
23
|
+
# | ~ ~~~~~^~~~~~~~
|
|
24
|
+
append_cflags("-Wno-shorten-64-to-32")
|
|
25
|
+
|
|
26
|
+
vendor = File.join('../../mandoc-1.14.6')
|
|
27
|
+
$INCFLAGS << " -I$(srcdir)/#{vendor}"
|
|
28
|
+
$VPATH << "$(srcdir)/#{vendor}"
|
|
29
|
+
mandoc_srcs = [
|
|
30
|
+
'chars.c',
|
|
31
|
+
'compat_ohash.c',
|
|
32
|
+
'eqn.c',
|
|
33
|
+
'mandoc.c',
|
|
34
|
+
'mandoc_aux.c',
|
|
35
|
+
'mandoc_msg.c',
|
|
36
|
+
'mandoc_ohash.c',
|
|
37
|
+
'mandoc_xr.c',
|
|
38
|
+
'mdoc.c',
|
|
39
|
+
'mdoc_argv.c',
|
|
40
|
+
'mdoc_macro.c',
|
|
41
|
+
'mdoc_markdown.c',
|
|
42
|
+
'mdoc_state.c',
|
|
43
|
+
'mdoc_validate.c',
|
|
44
|
+
'msec.c',
|
|
45
|
+
'read.c',
|
|
46
|
+
'roff.c',
|
|
47
|
+
'tag.c',
|
|
48
|
+
'tbl.c',
|
|
49
|
+
'tree.c',
|
|
50
|
+
'mdoc_man.c',
|
|
51
|
+
]
|
|
52
|
+
$srcs = ['rb_mandoc.c', *mandoc_srcs]
|
|
53
|
+
|
|
54
|
+
# Makes all symbols private by default to avoid unintended conflict
|
|
55
|
+
# with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
|
|
56
|
+
# selectively, or entirely remove this flag.
|
|
57
|
+
append_cflags("-fvisibility=hidden")
|
|
58
|
+
|
|
59
|
+
create_makefile("mandoc/mandoc")
|