Commit Graph

66 Commits

Author SHA1 Message Date
Robin Krahl
1adeafe909
Add vim integration to readme
This patch adds information about calling rusty-man from vim to the
readme.
2020-07-24 22:57:18 +02:00
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.
2020-07-24 18:10:53 +02:00
Robin Krahl
af1b81dd57
Release v0.1.1
This patch release fixes some minor issues with the documentation
displayed on crates.io.
2020-07-24 14:26:25 +02:00
Robin Krahl
54dd0d9ee9
Add homepage and repository links to Cargo.toml 2020-07-24 14:23:31 +02:00
Robin Krahl
411b1834b1
Use absolute links in readme
This fixes missing links on crates.io.
2020-07-24 14:21:37 +02:00
Robin Krahl
0c22a6d393
Release v0.1.0 2020-07-24 14:16:34 +02:00
Robin Krahl
ae51e80d46
Update keywords and excludes in Cargo.toml 2020-07-24 13:47:55 +02:00
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.
2020-07-24 13:45:23 +02:00
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.
2020-07-24 13:36:17 +02:00
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.
2020-07-24 13:18:35 +02:00
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>
2020-07-24 12:42:38 +02:00
Robin Krahl
0efe00e05e
Mention default sources in doc comment 2020-07-24 12:18:38 +02:00
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.
2020-07-24 12:17:17 +02:00
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)
2020-07-24 12:09:40 +02:00
Robin Krahl
162cae5bee
Change name for ItemType::Impl to Implementation(s) 2020-07-24 00:11:03 +02:00
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.
2020-07-22 23:57:57 +02:00
Robin Krahl
f4b0cba641
List implementations for all elements
With this patch, we list trait implementations, auto trait
implementations and blanket implementations, where applicable.
2020-07-22 23:56:31 +02:00
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.
2020-07-22 23:21:14 +02:00
Robin Krahl
8df4df57a5
Use html5ever::local_name in parser.rs 2020-07-22 22:37:43 +02:00
Robin Krahl
87e4066579
List definitions for enum variants 2020-07-22 22:36:23 +02:00
Robin Krahl
eb0f85d174
List fields for structs 2020-07-22 22:33:19 +02:00
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.
2020-07-22 22:19:46 +02:00
Robin Krahl
853f5a8120
List methods and deref methods
This patch adds support for methods and deref methods.
2020-07-22 21:30:45 +02:00
Robin Krahl
8bfb7393e5
List variants for enums
This patch updates parse_item_doc to look for variants.
2020-07-22 19:37:48 +02:00
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.
2020-07-22 18:03:31 +02:00
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.
2020-07-22 17:50:19 +02:00
Robin Krahl
627830dcbe
Store ItemType in doc::Doc
This allows us to display more information for a member and change the
documentation format depending on the type.
2020-07-22 17:43:18 +02:00
Robin Krahl
e410e2e19f
Store group ID and name in item type
Previously, we maintained a list of headings and HTML element IDs for
item types in parser.rs.  As we now have a complete ItemType enum, we
can use ItemType methods to provide this data.
2020-07-22 17:31:42 +02:00
Robin Krahl
9f0497932f
Use only direct childs of #main for description
Some elements, for example std::io::ErrorKind, have nested docblocks in
their type-decl docblock.  This would lead to a wrong description
because we pick the first non-type-decl docblock for the description.

With this patch, we require that the description docblock is a direct
child of #main to fix this issue.
2020-07-22 17:19:23 +02:00
Robin Krahl
f799d860ca
Import item types from librustdoc
Previously, our ItemType enum only had three values: Module, Item and
Member.  With this patch we import the ItemType variants from librustdoc
(see html/item_type.rs) for better compatibility and easier parsing.
2020-07-22 17:15:00 +02:00
Robin Krahl
bb3b361d02
Improve rendering of module members
This patch improves the rendering of module members:  Instead of the
full name of the member, we now display only the last part.  This also
fixes a bug where we would use the HTML instead of the text content for
the member name.

And we also display the description next to the member name.  As we
cannot extract the content of the description element (kuchiki nodes do
not have an inner_html method), we use the text representation instead.
Otherwise we would get formatting problems when rendering the
documentation.
2020-07-21 23:55:00 +02:00
Robin Krahl
a97c9e5a0f
Refactor viewer module
This patch refactors the viewer module:
- The `text` option is renamed to `plain`.
- The TextViewer and RichViewer structs are replaced by a new TextViewer
  struct that handles the basic documentation structure and uses a
  Printer implementation for formatting.
- The new structs PlainTextRenderer and RichTextRenderer implement the
  Printer trait.
- The Printer trait and the TextViewer struct are placed in the
  viewer::text module.  The Printer implementations are placed in the
  plain and rich submodules.

This reduces code duplication and makes it easier to render more complex
documentation items.
2020-07-21 23:24:34 +02:00
Robin Krahl
06851357a2
Extract parse_module_doc from parse_item_doc
Previously, we assumed that we can parse the documentation for a module
and an item (struct, trrait, …) with the same procedure.  This approach
was too simple.  For example, functions in a module are listed in a
table while the methods of a struct are listed in divs grouped by
subheadings.

Therefore, we extract the parsing of module documentation into a new
function parse_module_doc.
2020-07-21 13:55:26 +02:00
Robin Krahl
60cb034c5a
Store item type for items
Previously, we assumed that we only have to differentiate between items
(= elements with their own documentation file) and members (= elements
described in the documentation file of their parent).  But this model
was too simple.  For example, there are big differences in the structure
of a module and a struct documentation file.

Therefore we introduce a new enum, ItemType, that stores the type of an
item.  This allows us to drop the member field of the Item struct and to
add the name of the member to the full name of the item.
2020-07-21 13:41:00 +02:00
Robin Krahl
9613235ccc
Store full name in doc::Doc
This patch adds a new field, name, to the doc::Doc struct for
documentation items.  It stores the fully qualified name of the
documented element.  Since we no longer require a title to identify an
item, we make the title optional.  If it is not set, we print the item
name instead.
2020-07-21 12:56:52 +02:00
Robin Krahl
94dff39c8a Introduce Name and Fqn types for names
Previosuly, we used strings to store item names.  Sometimes, these
strings would refer to full paths (e. g. kuchiki::NodeDataRef::as_node),
sometimes to local paths (e. g. NodeDataRef::as_node) and sometimes only
to the last item (e. g. as_node).

With this patch, we add two new types:  doc::Name is a name without a
semantic meaning, so it could be any of the cases mentioned above.
doc::Fqn is a wrapper around doc::Name that stores fully-qualifier
names, i. e. names where the first element is the crate.
2020-07-21 12:49:23 +02:00
Robin Krahl
58929bc98b
Use pattern search-index*.js for index files
Previously, we always tried to load the search index from the
search-index.js file.  But rustdoc may add a suffix to the file name, so
with withs patch, we use the first file that matches the pattern
search-index*.json.  This makes it possible to use rusty-man with the
documentation installed by rustup.
2020-07-20 13:47:35 +02:00
Robin Krahl
d0c73d2523
List members in module documentation
This patch adds support for listing the module members on its
documentation page.  This is quite easy as the items are displayed in a
single table per item type.
2020-07-20 11:48:29 +02:00
Robin Krahl
3d4fac0d5c Skip associated types in search index
When searching for a keyword, we typically don’t want to match an
associated type.  With this patch, we skip associated types when
searching items in the search index.
2020-07-20 10:44:37 +02:00
Robin Krahl
1b8a2c23f6 Fix wrong command in example usage 2020-07-20 10:29:55 +02:00
Robin Krahl
baef1a06b0
Extend contributing guide
This patch extends the CONTRIBUTING.md file with more information on
possible tasks, the test suite and the code checks.
2020-07-20 10:23:28 +02:00
Robin Krahl
a6048238b1
Add doc comment for main.rs
This patch adds a doc comment to the main.rs file that describes the
structure of rusty-man.
2020-07-20 09:20:24 +02:00
Robin Krahl
1128919f1f
Add installation and contributing information
This patch extends the README.md file and adds the INSTALL.md and
CONTRIBUTING.md files with more detailed information.
2020-07-20 01:42:30 +02:00
Robin Krahl
e1ef283159 Check parent for search index items
For members, the path listed in the search index does not point to the
parent item but to the path of the parent item.  To get the parent item,
we have to access the parent field and lookup the index in the crate’s
path list.
2020-07-20 01:42:26 +02:00
Robin Krahl
1bd5cf8fbe Add --no-search option
If there is no exact match for the keyword, we read the search indexes
of all sources.  This patch adds the option --no-search that disables
this feature.
2020-07-20 00:03:59 +02:00
Robin Krahl
f6eaab94a0
Fix path for search index items
rustdoc clears the path of an item in the search index if it is equal to
the path of the previous item (see build_index in html/render.rs).
Previously, we used the crate name if the path was empty.  With this
patch, we use the past of the last item instead.
2020-07-19 23:48:11 +02:00
Robin Krahl
0c080ab401
Show error message if an item could not be found
With the introduction of the search index, I mistakenly removed the
error message for missing items.  This patch fixes that.
2020-07-19 23:48:05 +02:00
Robin Krahl
bd71f41458
Also match patch in Index::find
Previously, we only compared the type names when searching for matches
in the search index.  With this patch, we also check the path:  If the
full name of the item ends with the keyword (prepended with :: to avoid
partial matches), we return a match.
2020-07-19 22:44:21 +02:00
Robin Krahl
61fdf31c0a
Read search index from search-index.js
With this patch, we read the search index generated by rustdoc.  It
allows us to suggest matching items if we don’t find an exact match.
2020-07-19 22:23:47 +02:00
Robin Krahl
d4dd4d6548
Run cargo doc before cargo test
This patch fixes the builds by running cargo doc before cargo test.
Without generated documentation, we don’t have anything to test.
2020-07-19 17:39:47 +02:00