90 Commits (c48711f3cf232c9c332ce2e9bc70c67a7635c4b0)
 

Author SHA1 Message Date
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 a37d7e0d6a
Pass viewer args to viewer implementations
This patch adds the ViewerArgs struct to the Opt struct that contains
the viewer-specific arguments.  It also adds a ViewerArgs argument to
the methods of the Viewer trait so that viewers can access these
arguments.

We also refactor the TextViewer implementations so that we can pass the
viewer arguments to the Printer constructor.

Currently, there are no viewer arguments, but we will add them in
upcoming patches.
4 years ago
Robin Krahl 81c9cf53d6
Print definitions as code instead of HTML
Previously, we renderer item and member definitions as HTML.  With this
patch, we print them as code so that they can be highlighted in the rich
text output.
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 d16f45e023
Wrap HTML and plain text in Text struct
This patch adds the Text struct to the doc module that is a wrapper for
a string that is available as HTML or as plain text.  This makes it
clearer what data is stored in the Doc and Example structs and what the
viewers should do with this data.
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 44fe71d5bb
Rewrap example in readme to 80 columns
This makes it easier to read the example e. g. on crates.io.
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
Robin Krahl 19398e340c
Remove spurious members from module documentation
With this patch, we require that the identifier element for a member in
the module documentation is a direct child of the table cell.  This
fixes problems with spurious member elements if there are more elements
in the table cell, e. g. stability annotations.
4 years ago
Robin Krahl bc3f1552ef
Fix definition for methods in documentation parser
This patch changes the documentation parser for methods to use the first
code child of the subheading as the definition instead of the first
child.  This fixes a problems when there is additional information in
the subheading, for example about the relevant traits.
4 years ago
Robin Krahl 64dd5a55ae
Use rustc --print sysroot for default sources
Previously, we were used /usr/share/doc/rust{,-doc}/html as a default
source, assuming that it would contain the standard library
documentation.  This is true if the user installed the Rust
documentation manually or using a package manager.  If they use rustup
instead, the documentation is placed in a subdirectory of ~/.rustup.

With this patch, we call `rustc --print sysroot` to determine the
installation directory of the currently activated Rust toolchain –
either the system Rust installation or a Rust installation managed by
rustup.  We then use `$(sysroot)/share/doc/…` as a default path for the
standard library documentation (with /usr as a fallback if the call to
rustc does not return a valid path).
4 years ago
Robin Krahl 4d7c7d4eab
Release v0.1.2
This patch release adds basic logging output and a new `-e`/`--examples`
option to extract only the examples from the documentation.  It also
fixes a bug when displaying the documentation for a function.
4 years ago
Robin Krahl 45a1a3d1f5
Add top-level heading to changelog 4 years ago
Robin Krahl e9aafd4650
Add more log messages
As I noticed when trying to debug an issue with a very large HTML file,
we still need more log messages that indicate what is currently going on
in rusty-man.  This patch adds some more log messages.
4 years ago
Robin Krahl 34857816e1
Add -e/--example option to only show examples
As requested here [0], this patch adds a new -e/--example option that
extracts the examples from the documentation string instead of printing
the full documentation for an item.  Syntax highlighting will be added
in the future.

[0] https://old.reddit.com/r/rust/comments/hx16j0/rustyman_a_commandline_viewer_for_rustdoc/fz3utjf/
4 years ago
Robin Krahl 1a242e5474
Fix definition selector for functions
Previosuly, we always used the selector ".docblock.type-decl" to select
the definition for an item.  But this did not work for functions.
Therefore we change the selector to "pre.fn" for functions.
4 years ago
Robin Krahl 221c345e1c
Add changelog entry for logging functionality
We introduced basic logging in commit e69e4af but didn’t update the
changelog.  This patch adds the missing changelog entry.
4 years ago
Robin Krahl c00a04b179
Fix v0.1.1 release date in changelog 4 years ago
Robin Krahl 1adeafe909
Add vim integration to readme
This patch adds information about calling rusty-man from vim to the
readme.
4 years ago
Robin Krahl e69e4af31c
Add basic logging with env_logger
This patch adds some basic info log messages to make it easier to debug
incompatible rustdoc output.  To show the messages, run rusty-man with
the environment variable RUST_LOG=info.
4 years ago
Robin Krahl af1b81dd57
Release v0.1.1
This patch release fixes some minor issues with the documentation
displayed on crates.io.
4 years ago
Robin Krahl 54dd0d9ee9
Add homepage and repository links to Cargo.toml 4 years ago
Robin Krahl 411b1834b1
Use absolute links in readme
This fixes missing links on crates.io.
4 years ago
Robin Krahl 0c22a6d393
Release v0.1.0 4 years ago
Robin Krahl ae51e80d46
Update keywords and excludes in Cargo.toml 4 years ago
Robin Krahl 0a1dd0838e
Update installation instructions
This patch adds information about installing from crates.io and suggests
checking out the latest release when installing from source.
4 years ago
Robin Krahl afe3b02a34
Update main and CLI doc comments
This patch updates the main module doc comment and the documentation
printed with rusty-man --help.
4 years ago
Robin Krahl 41dd007390
Use crossterm instead of termion
With this patch, we replace the termion dependency with crossterm.  This
should make it possible to compile and run rusty-man on other platforms
than Unix.
4 years ago
Robin Krahl 0d75176f59
Update readme
This patch updates the readme with better usage examples and with the
documentation for rusty-man itself.

Signed-off-by: Robin Krahl <robin.krahl@ireas.org>
4 years ago
Robin Krahl 0efe00e05e
Mention default sources in doc comment 4 years ago
Robin Krahl ec6be9fbb1
Replace - with _ in crate lookup
rustdoc normalizes the name of a crate by replacing hyphens with
underscores.  With this patch, we also perform this normalization when
looking up a crate.
4 years ago
Robin Krahl fc7d2c7ee9
Format text output look like man
With this patch, we change our rich and plain viewer implementations to
format their output similar to the output of man.  This means:
- Adding a title with the current crate, documentation item and
  “rusty-man”
- Printing headings at indent levels 0, 3, 6 and printing content with
  indent 6, 12
- Printing headings bold and uppercase (level 1) or bold (levels 2, 3)
4 years ago
Robin Krahl 162cae5bee
Change name for ItemType::Impl to Implementation(s) 4 years ago
Robin Krahl f709a0d46d
Only print headings with level <= 3 bold
Previously, all headings were printed with a bold font.  With this
change, we limit this to headings of level 1 to 3 to make the output
more readable.
4 years ago
Robin Krahl f4b0cba641
List implementations for all elements
With this patch, we list trait implementations, auto trait
implementations and blanket implementations, where applicable.
4 years ago
Robin Krahl 05cfb47a47
Refactor Doc creation in parser into MemberDocs
This patch introduces the helper struct MemberDocs that wraps a Vec<Doc>
that allows us to simplify the parser code.  The MemberDocs struct takes
care of creating Doc instances using the names, definitions and
descriptions of member items.
4 years ago
Robin Krahl 8df4df57a5
Use html5ever::local_name in parser.rs 4 years ago
Robin Krahl 87e4066579
List definitions for enum variants 4 years ago
Robin Krahl eb0f85d174
List fields for structs 4 years ago
Robin Krahl adb6cc6ed9
List associated types and methods for traits
With this patch, we list the associated types and the provided and
required methods in the trait documentation.
4 years ago
Robin Krahl 853f5a8120
List methods and deref methods
This patch adds support for methods and deref methods.
4 years ago
Robin Krahl 8bfb7393e5
List variants for enums
This patch updates parse_item_doc to look for variants.
4 years ago
Robin Krahl 958019449d
Add MemberGroup struct for groups of members items
Previosuly, we stored the members as a vector of vectors, group by a
string -- their title.  This was very hard to read and also too simple:
For example, there can be multiple blocks of methods in the
documentation for a struct.  Therefore we introduce a new type,
MemberGroup, that represents a group of member items with an optional
title.
4 years ago
Robin Krahl f08490eeff
Display member type in viewer::text::TextViewer
Previously, we only displayed the member name when viewing the
documentation of a member.  With this patch, we use the ItemType enum to
also print the type of the member.

For consistency, we remove the title field from doc::Doc that was
previously used for the titles of modules and items and use the same
title as for members.  While we lose the links to the parent items,
these were not particularly helpful anyway.  If we want to, we could
also generate them from the item name.
4 years ago