Commit Graph

167 Commits

Author SHA1 Message Date
Robin Krahl
3d1670e526
Release v0.4.3
This patch release adds support for Rust 1.53.0 and for non-default
target directories.
2021-06-19 13:11:19 +02:00
Robin Krahl
3d20513742
Update arc-swap dependency to 0.4.8
This patch updates the arc-swap dependency from 0.4.7 to 0.4.8 as the
old version has been yanked.
2021-06-19 12:53:35 +02:00
Robin Krahl
f336104a60
Don’t use Option::zip to keep MSRV
Option::zip was introduced in 1.46.0 but our MSRV is 1.40.0.
2021-06-18 17:32:31 +02:00
Robin Krahl
68f20c8d8c
Add support and tests for Rust 1.53.0
This patch adds tests for Rust 1.53.0 and adapts the HTML parser to
handle method and implementations list inside of details elements.
2021-06-18 17:17:33 +02:00
Robin Krahl
0c3cae34e8
Add changelog entry for target dir lookup 2021-06-14 17:31:18 +02:00
Robin Krahl
04432813bd
Check CARGO_TARGET_DIR and CARGO_BUILD_TARGET_DIR
Previously, we assumed that the documentation generated by cargo is
placed in the target directory relative to the current working
directory.  This is only true if the CARGO_TARGET_DIR and
CARGO_BUILD_TARGET_DIR environment variables are not set.

With this patch, we check the CARGO_TARGET_DIR and
CARGO_BUILD_TARGET_DIR environment variables to determine the target
directory.  It could also be set in the Cargo configuration file, but
that would be too complicated to check.  In the future, we might be able
to use the cargo config subcommand to determie the target directory.
2021-06-14 17:07:47 +02:00
Robin Krahl
601ec251f8
Add support for multiple formats to test cases
This patch adds support for multiple rustdoc output formats to the test
suite.  This is a preparation for adding support for rustdoc’s JSON
output.
2021-06-06 18:58:35 +02:00
Robin Krahl
b0485d515c
Rename parser module to parser::html
This patch renames the parser module to parser::html as a preparation
for adding a JSON backend.
2021-06-06 18:56:51 +02:00
Robin Krahl
2955560060
Release v0.4.2
This patch releases adds support for the new search index format (Rust
1.52.0 and later).
2021-06-06 14:59:15 +02:00
Robin Krahl
686b8bb1b0
Add --locked flag to cargo install invocation
This patch adds the --locked flag to the cargo install invocation in
INSTALL.md as this makes sure that the users ends up with tested and
working dependency versions.
2021-06-06 13:59:59 +02:00
Robin Krahl
48405481d0
Support new search index format (Rust 1.52)
This path adds support for the new search index format introduced in
Rust 1.52.0.  With this new format, the index items are no longer
serialized as an array of structs but as arrays of the struct fields.
2021-06-06 13:00:50 +02:00
Robin Krahl
37ff920d30
Fix clippy lints 2021-06-06 11:59:43 +02:00
Robin Krahl
d0292a0dba
Add tests for Rust 1.52.1
This patch adds tests for Rust 1.52.1 by copying the snapshots from
1.52.0.
2021-06-06 11:52:00 +02:00
Robin Krahl
0a17d717d7
Add tests for Rust 1.52.0
This patch adds tests for Rust 1.52.0.  With Rust 1.52.0, the format of
the search index changed so we have to disable the search index tests.
Otherwise we can copy the snapshots with only small modifications taking
into account the change from simple quotes and apostrophes ("') to
typographically correct ones (“”’).
2021-06-06 11:51:49 +02:00
Robin Krahl
d7cc2dd6b9
Add tests for Rust 1.51.0
This patch adds test cases for Rust 1.51.0.  We have to disable the
struct_anyhow_error test case as the structure of the Deref method
sections has changed.
2021-06-06 11:23:01 +02:00
Robin Krahl
ea183be56d
Add tests for Rust 1.50.0
This patch adds tests for Rust 1.50.0 which we can mostly copy from
1.49.0.  There is only a small change to the abbreviated descriptions in
the search index and to edition-specific code.
2021-06-05 21:14:58 +02:00
Robin Krahl
c4e49a98ad
Add tests for Rust 1.49.0
This patch adds tests for Rust 1.49.0 which we can just copy from 1.48.0
as there were no changes.
2021-06-05 21:08:03 +02:00
Robin Krahl
4ed21183df
Add tests for Rust 1.48.0
With Rust 1.48.0, support for link shorthands, i. e. `[Test]` instead of
`[Test][]`, was added.  Therefore, some of the links are now rendered
correctly.  Otherwise we can just copy the snapshots and don’t need any
code changes.
2021-06-05 21:02:58 +02:00
Robin Krahl
6232585d36
Add o command for opening items to tui viewer
This patch adds the o command to the tui viewer that can be used to open
items.  The command uses the same lookup logic as the rusty-man program:
First, it tries to find a direct match.  If none is found, it uses the
search index to find partial matches.
2020-10-12 01:08:00 +02:00
Robin Krahl
44b1405595
Move item lookup logic into Sources struct
This match adds the Sources struct that is a wrapper for a vector of
Source structs.  It now contains the lookup logic that was previously
contained in functions in main.rs.
2020-10-12 00:28:51 +02:00
Robin Krahl
2c1b91462e
Release v0.4.1
This patch release fixes an issue with the pager configuration.
2020-10-11 22:41:05 +02:00
Robin Krahl
f9a0b2f579
Add --pager option to set the pager
This patch adds the --pager command-line option to set the pager used by
the plain and rich viewers.
2020-10-11 22:25:14 +02:00
Robin Krahl
e425da5a24
Use LESS environment variables for less options
Previously, we would either use the pager set in the PAGER environment
variable or "less -cr" for the rich and plain viewer.  This caused
problems if, for example, the PAGER environment variable was set to
"less", see ticket #22:
	https://todo.sr.ht/~ireas/rusty-man/22

To fix this issue, we now use the LESS environment variable to set the
less options.  This makes sure that setting PAGER does not override the
options.
2020-10-11 22:09:56 +02:00
Robin Krahl
56cb98e867
Release v0.4.0
This minor release introduces a new interactive viewer, tui.  It also
adds syntax highlighting for code in the documentation and support for
Rust 1.47.0.
2020-10-09 12:16:01 +02:00
Robin Krahl
d4971ba4ac
Add screenshot to readme 2020-10-09 12:15:33 +02:00
Robin Krahl
07996d9dd6
Ignore match_like_matches_macro clippy lint
This lint tells us to use the std::matches! macro instead of a match or
if let expression that yields a bool.  But the matches! macro was added
in Rust 1.42, and our MSRV is 1.40.  I don’t want to bump the MSRV only
for this change, so we ignore the lint.
2020-10-09 11:18:38 +02:00
Robin Krahl
65c3fd7639
Update documentaion for tui viewer 2020-10-09 11:18:30 +02:00
Robin Krahl
ce06129976
Remove Notable Traits section from definitions
Rust 1.47.0 introduced the Notable Traits section that lists information
about types used in code block.  As we only want to display the code
block itself without meta-information, this patch ignores the
notable-traits class when extracting the text from nodes.
2020-10-08 21:10:35 +02:00
Robin Krahl
9832c22b4d
Add tests for Rust 1.47.0
This patch adds unit tests for the new Rust 1.47.0 release.  Except for
the new Notable Traits section, we’re already parsing the output
correctly.
2020-10-08 21:07:52 +02:00
Robin Krahl
9dd54e3219
Add vim-like keybindings to tui viewer
This patch adds vim-like keybindings to the tui viewer:  hjkl for
navigation, G and g (instead of gg) for End and Home, and Ctrl+F and
Ctrl+B for Page Down and Up.
2020-10-08 11:00:48 +02:00
Robin Krahl
7756803e35
Remove textwrap dependency
The textwrap dependency was added mistakenly.
2020-10-08 10:33:39 +02:00
Robin Krahl
b93dbca7f0
Replace ansi_term, atty, terminal_size with termion
In the last patch, we added the termion dependency for the tui viewer.
With this patch, we remove the ansi_term, atty and terminal_size
dependencies and use termion instead.
2020-10-08 10:32:05 +02:00
Robin Krahl
8db34e33b2
Use termion backend for cursive
With this patch, we replace cursive’s default ncurses backend with the
termion backend.  This has multiple reasons:
- The ncurses backend has safety issues, see [0].
- ncurses requires a pre-installed library and a C compiler, introducing
  additional build dependencies.  Termion is implemented in Rust only.
- ncurses does not work on Windows, while termion works in all terminals
  that support ANSI escape codes.

Per default, the termion backend does not buffer the output which may
cause flickering [1].  Therefore, we also use the
cursive_buffered_backend that buffers the output and fixes the
flickering problem.

[0] https://github.com/gyscos/cursive/issues/488
[1] https://github.com/gyscos/cursive/issues/142
2020-10-08 10:30:17 +02:00
Robin Krahl
568fb0acc8
Use cursive-markup to replace HtmlView
We’ve moved the HtmlView into a separate crate, so we can replace our
own HtmlView with cursive_markup::MarkupView.  We only have to implement
a custom Renderer that applies the syntax highlighting to code snippets.
2020-10-08 10:00:26 +02:00
Robin Krahl
4c5d5808aa
Add links to module items
This patch adds links to the items in the module member list.  This only
applies for the tui viewer, as the links wouldn’t provide any additional
information for the plain and rich viewers.
2020-10-06 20:35:25 +02:00
Robin Krahl
8e8f7728e2
Replace Option::zip with custom function
In the previous commit, we used the Option::zip method to make querying
the focus and the links in the HtmlView struct easier.  But Option::zip
has only been added in Rust 1.46, so we replace it with a custom utility
function to keep compatibility with Rust 1.40.
2020-10-06 19:43:06 +02:00
Robin Krahl
e222a1f443
Add TUI viewer using cursive
This patch adds a new viewer, tui, that provides an interactive
interface using cursive.  This viewer makes it possible to follow links
to other documentation items and to open external links in a web
browser.
2020-10-06 19:19:13 +02:00
Robin Krahl
4260aab85a
Display link targets in rich viewer
Previously, we only used the underline effect to highlight links in the
rich viewer, but we did not provide any information about their target.
With this patch, we print a list of link at the end of a block, similar
to the plain text viewer.
2020-10-06 14:42:49 +02:00
Robin Krahl
6ea5f070d2
Remove Decorator::show_links field
We are currently always listing the links in the plain text viewer when
rendering HTML, so we no longer need the show_links field that could be
used to disable link listing.
2020-10-06 11:34:15 +02:00
Robin Krahl
bf47310f51
Fix link formatting in rich viewer
When changing the viewer to use the text-style crate, we mistakenly
changed the format for links in the rich viewer from underline to bold.
This patch fixes that mistake.
2020-10-04 20:25:11 +02:00
Robin Krahl
ae1e7ebddf
Use custom rich text decorator
This patch changes the rich viewer to use a custom rich text decorator.
As we use colors to highlight code, and as we print the string text with
a bold font, we don’t need a backtick or an asterix to indicate these
elements.
2020-10-04 20:22:52 +02:00
Robin Krahl
f92fc3e9f6
Refactor HTML processing into viewer::utils
This patch moves the HTML processing (i. e. syntax highlighting for code
snippets) into the viewer::utils method.  This allows us to use it for
other viewers too.
2020-10-04 19:52:23 +02:00
Robin Krahl
ecf810929a
Add syntax highlighting for doc comments
This patch adds syntax highlighting for code blocks in the doc comments.
Previously, we only highlighted the definition of the documented
elements.  With this patch, we also highlight code blocks in the doc
blocks, like examples.
2020-10-03 19:06:21 +02:00
Robin Krahl
ecc05ddc7d
Update html2text dependency to v0.2.1
This patch updates the html2text dependency to v0.2.1.  This release
fixed the handling of preformatted blocks, allowing us to add syntax
highlighting for code blocks in the next patch.
2020-10-03 19:04:45 +02:00
Robin Krahl
970277d32c
Refactor syntax highlighting into viewer::utils
This patch introduces the viewer::utils::Highlighter struct that takes
care of syntax highlighting.  This will make it easier to use syntax
highlighting from others viewers once we add them.
2020-10-03 15:57:09 +02:00
Robin Krahl
9458b280d4
Use text-style crate to format text
This patch replaces the direct text formatting with ansi_term with the
text-style crate.  This also allows us to directly convert the syntect
annotations to styled strings.
2020-10-03 15:44:00 +02:00
Robin Krahl
ecb3d40c59
Use ansi_term, atty, terminal_size
This patch replaces the crossterm dependency with ansi_term, atty and
terminal_size.  This allows us for an easier integration with the
text_style crate in an upcoming patch, and it reduces the total number
of dependencies from 166 to 160.

This means that we drop support for non-ANSI terminals, but as this only
affects old versions of cmd.exe/PowerShell, we don’t care about it.
2020-10-02 13:10:37 +02:00
Robin Krahl
225e19a024
Use merge to merge arguments and configuration
This patch adds the merge dependency to automatically merge the
command-line arguments and the settings from the configuration file.
This means that we no longer have to manually maintain the Args::merge
function.
2020-09-20 22:18:28 +02:00
Robin Krahl
0bf2f15186
Refactor text viewers into ManRenderer
This patch introduces the ManRenderer trait that can be used by viewers
that render documentation in a man-like style.  This is a more general
version of the previous Printer trait.
2020-09-17 17:05:09 +02:00
Robin Krahl
b7f5d3b855
Introduce viewer::utils module
This patch adds the viewer::utils module with utility methods for viewer
implementations.  It contains common functions for text rendering and
syntax highlighting.
2020-09-17 17:05:02 +02:00