61 Commits (6dc75f0c5dfd0733e2333f2271219815cd51ad4e)

Author SHA1 Message Date
Robin Krahl 6dc75f0c5d
Add support for Rust 1.54.0, 1.55.0, 1.56.0
This patch adds tests for Rust 1.54.0, 1.55.0 and 1.56.0.  To make the
tests pass, we have to take care of some changes like more details
elements and changed heading levels.  To make it easier to generate the
tests for new Rust versions, we also add two bash scripts that take care
of that.
3 years ago
Robin Krahl 730bca7a9e
Scroll by page on PageUp/PageDown in tui viewer
Previosuly, we would always scroll by five lines if the PageUp or
PageDown button is hit in the tui viewer.  With this patch, we customize
the scroll speed to one page (minus one line).
3 years ago
Robin Krahl 7f7d85fc40
Bump MSRV to 1.45.0
Due to the update to cursive_core 0.2, we have to increase the MSRV to
1.45.0.
3 years ago
Robin Krahl 3d1670e526
Release v0.4.3
This patch release adds support for Rust 1.53.0 and for non-default
target directories.
3 years ago
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.
3 years ago
Robin Krahl 0c3cae34e8
Add changelog entry for target dir lookup 3 years ago
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.
3 years ago
Robin Krahl 2955560060
Release v0.4.2
This patch releases adds support for the new search index format (Rust
1.52.0 and later).
3 years ago
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.
3 years ago
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.
3 years ago
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 (“”’).
3 years ago
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.
3 years ago
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.
3 years ago
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.
3 years ago
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.
3 years ago
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.
4 years ago
Robin Krahl 2c1b91462e
Release v0.4.1
This patch release fixes an issue with the pager configuration.
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
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.
4 years ago
Robin Krahl 0c38bf9606
Remove suffix from duplicate members
We use the HTML ID of a member element to get its name.  If there are
multiple members with the same type and name (e. g. from a Deref
implementation), the ID has a suffix to make it unique.  Previosuly, we
just interpreted this suffix as part of the name.  With this patch, we
strip the suffix and only use the actual name.
4 years ago
Robin Krahl 642bec6687
Release v0.3.0
This minor release adds support for Rust 1.46.0 and significantly
improves the test suite.
4 years ago
Robin Krahl c97ac33dc9
Add test case for Index::find
As we only support the new search index format introduced in April 2020,
the test is only run for Rust >= 1.44.0.
4 years ago
Robin Krahl 77a9163bb1
Add test case for Parser::find_member 4 years ago
Robin Krahl 229b1bdd5c
Add test suite for Rust 1.46.0 4 years ago
Robin Krahl 71280ddb16
Refactor member lookup
Up to rustdoc version 1.45.2, the code element containing the definition
of a member always had the ID "<name>.v".  This ID has been dropped in
rustdoc 1.46.0.  Therefore we now look for members by searching for the
heading which has the id "<ty>.<name>" (for all possible types).
4 years ago
Robin Krahl 628377c83b
Refactor test suite to check multiple versions
This patch refactors the test suite:
- Instead of always generating the documentation with the available
  rustdoc version, we now store generated documentation for all
  supported rustdoc versions in the test/html directory.
- Instead of using one snapshot per test case, we now use one snapshot
  per test case and rustdoc version.
4 years ago
Robin Krahl 5b2003b979
Respect item type in documentation lookup
Sometimes, there might be multiple items with the same name, for example
std::u8 is both a module and a primitive.  Previously, we could not
determine which one Source::load_doc would return.  With this patch, we
add the ty parameter that can be used to filter by the item type.
4 years ago
Robin Krahl c672a65d59
Add item type to the IndexItem struct
Previously, we only used the name and the description to represent index
items.  Therefore we consider e. g. the std::u8 module and the std::u8
primitive to be the same.  With this patch, we also take the item type
into account when comparing index items.
4 years ago
Robin Krahl 76845785ee
Release v0.2.0
This minor release adds support for syntax highlighting of code snippets
and for configuration files.
4 years ago
Robin Krahl 28c025fd4f
Add --width and --max-width options
This patch adds the --width option to select a fixed output width and
the --max-width to set a maximum output width if the width is
dynamically set using the terminal size.
4 years ago
Robin Krahl 1a518d7509
Add integration tests
This patch adds an integration test suite using the insta crate for
snapshot testing.  The test suite is tested for all supported Rust
versions and should always succeed for the MSRV (currently 1.40.0) and
the current stable Rust version.

However there are some minor changes in the configuration format between
Rust versions, so tests that don’t work on all supported Rust versions
are marked with the ignore attribute.  But even the ignored tests should
work on the stable Rust release.
4 years ago
Robin Krahl 17e407d6b1
Improve line breaks for code
kuchiki’s NodeRef::text_contents() implementation does not take into
account the value of the display attribute or line breaks caused by br
elements.  Therefore we have to implement our own converter that
produces readable output for the HTML code generated by rustdoc.
4 years ago
Robin Krahl a6b2d570b3
Add --config-file option to set custom config file
This patch adds the --config-file option that allows the user to specify
a custom configuration file (or to disable reading configuration files
if the option is set to "-").
4 years ago
Robin Krahl e5ee4df73b
Add support for configuration files
With this patch, we load defaults for the command-line arguments from
the configuration file located in the user configuration directory
according to the XDG Base Directory Specification.
4 years ago
Robin Krahl c48711f3cf
Add --no-syntax-highlight and --theme options
This patch adds two new command-line options for the rich text viewer:
--no-syntax-highlight and --theme.  --no-syntax-highlight disables the
syntax highlighting for code snippets.  --theme selects a color theme
for the syntax highlighting.
4 years ago
Robin Krahl dc7b5b1eca
Add syntax highlighting for code snippets
This patch uses syntect to add syntax highlighting for code snippets in
the rich text output.  Currently, this only applies to the examples
printed with the -e/--examples option.
4 years ago
Robin Krahl 44028e228a
Release v0.1.3
This patch release adds support for documentation generated with Rust
1.45.0 and fixes some minor bugs in the documentation parser.  It also
adds the documentation downloaded using rustup to the default sources.
4 years ago
Robin Krahl 754e0eecae
Fix list of methods for Rust 1.45
As described in the previous commit, Rust 1.45 changed the ID of the
methods subheading from "methods" to "implementations".  The last patch
fixed this for the trait implementations, this patch updates the method
group parser with the new IDs.
4 years ago
Robin Krahl ef8f6fa365
Fix trait implementation list for Rust 1.45
In older Rust versions, trait implementations were listed under the
heading with the id "implementations" and in the div with the id
"implementations-list".  Since Rust 1.45, the method heading has the id
"implementations" and the trait implementations have the ids
"trait-implementations" and "trait-implementations-list".

This patch updates the parser with these new IDs while also checking the
old IDs for older documentation.
4 years ago
Robin Krahl 3c06846a30
Sort implementations alphabetically
For consistency and easier testing, we sort the implementation items
alphabetically by their name and their definitions.
4 years ago
Robin Krahl ae0a741d5a
Extract description of module items as HTML
Previously, we only showed plain text versions of the item descriptions
in the module overview due to a formatting issue.  As this issue
disappeared, we can now use the HTML version of the description.
4 years ago
Robin Krahl 6ca9d90e46
Fix group and ID for typdef items
This patch fixes the group and ID stored in the ItemType enum for the
ItemType::Typedef variant so that typedefs show up in the module
summary.
4 years ago
Robin Krahl cbc4965902
Show definition for type defs
As in the previous commit, we have to use the selector "pre.typedef"
instead of ".docblock.type-decl" to select the definition for type defs.
4 years ago
Robin Krahl f0245bada3
Show definition for constants
Similar to the fix for functions in 1a242e5, we have to use a different
selector to query the definition for constants, "pre.const" instead of
".docblock.type-decl".
4 years ago