rustdoc::html::render - Rust (original) (raw)

Expand description

Rustdoc’s HTML rendering module.

This modules contains the bulk of the logic necessary for rendering a rustdoc clean::Crate instance to a set of static HTML pages. This rendering process is largely driven by the format! syntax extension to perform all I/O into files and streams.

The rendering process is largely driven by the Context and Cachestructures. The cache is pre-populated by crawling the crate in question, and then it is shared among the various rendering threads. The cache is meant to be a fairly large structure not implementing Clone (because it’s shared among threads). The context, however, should be a lightweight structure. This is cloned per-thread and contains information about what is currently being rendered.

The main entry point to the rendering system is the implementation ofFormatRenderer on Context.

In order to speed up rendering (mostly because of markdown rendering), the rendering process has been parallelized. This parallelization is only exposed through the crate method on the context, and then also from the fact that the shared cache is stored in TLS (and must be accessed as such).

In addition to rendering the crate itself, this module is also responsible for creating the corresponding search index and source file renderings. These threads are not parallelized (they haven’t been a bottleneck yet), and both occur before the crate is rendered.

context πŸ”’

ordered_json πŸ”’

print_item πŸ”’

search_index πŸ”’

sidebar πŸ”’

sorted_template πŸ”’

span_map πŸ”’

type_layout πŸ”’

write_shared πŸ”’

Rustdoc writes aut two kinds of shared files:

AllTypes πŸ”’

ImplRenderingParameters πŸ”’

IndexItem πŸ”’

Struct representing one entry in the JS search index. These are all emitted by hand to a large JS file at the end of cache-creation.

IndexItemFunctionType πŸ”’

Full type of functions/methods in the search index.

ItemEntry πŸ”’

ItemInfo πŸ”’

RenderType πŸ”’

A type used for the search index.

StylePath πŸ”’

AssocConstValue πŸ”’

AssocItemLink πŸ”’

AssocItemRender πŸ”’

Specifies whether rendering directly implemented trait items or ones from a certain Deref impl.

ItemSection πŸ”’

RenderMode πŸ”’

For different handling of associated items from the Deref target of a type rather than the type itself.

RenderTypeId πŸ”’

ShortItemInfo πŸ”’

MAX_FULL_EXAMPLES πŸ”’

NUM_VISIBLE_LINES πŸ”’

assoc_const πŸ”’

assoc_href_attr πŸ”’

Build a (possibly empty) href attribute (a key-value pair) for the given associated item.

assoc_method πŸ”’

assoc_type πŸ”’

collect_paths_for_type πŸ”’

Returns a list of all paths used in the type. This is used to help deduplicate imported impls for reexported types. If any of the contained types are re-exported, we don’t use the corresponding entry from the js file, as inlining will have already picked up the impl

document πŸ”’

document_full πŸ”’

document_full_collapsible πŸ”’

document_full_inner πŸ”’

document_item_info πŸ”’

Add extra information about an item such as:

document_short πŸ”’

Writes a documentation block containing only the first paragraph of the documentation. If the docs are longer, a β€œRead more” link is appended to the end.

ensure_trailing_slash πŸ”’

extract_for_impl_name πŸ”’

get_filtered_impls_for_reference πŸ”’

Returns the list of implementations for the primitive reference type, filtering out any implementations that are on concrete or partially generic types, only keeping implementations of the form impl<T> Trait for &T.

get_id_for_impl πŸ”’

item_ty_to_section πŸ”’

notable_traits_button πŸ”’

notable_traits_decl πŸ”’

notable_traits_json πŸ”’

portability πŸ”’

render_all_impls πŸ”’

render_assoc_item πŸ”’

render_assoc_items πŸ”’

render_assoc_items_inner πŸ”’

render_attributes_in_code πŸ”’

render_attributes_in_pre πŸ”’

render_call_locations πŸ”’

Generates the HTML for example call locations generated via the –scrape-examples flag.

render_deref_methods πŸ”’

derefs is the set of all deref targets that have already been handled.

render_impl πŸ”’

render_impl_summary πŸ”’

render_impls πŸ”’

render_markdown πŸ”’

Render md_text as markdown.

render_rightside πŸ”’

render_stability_since_raw πŸ”’

render_stability_since_raw_with_extra πŸ”’

Writes a span containing the versions at which an item became stable and/or const-stable. For example, if the item became stable at 1.0.0, and const-stable at 1.45.0, this function would write a span containing β€œ1.0.0 (const: 1.45.0)”.

scrape_examples_help πŸ”’

short_item_info πŸ”’

Render the stability, deprecation and portability information that is displayed at the top of the item’s documentation.

should_render_item πŸ”’

since_to_string πŸ”’

small_url_encode πŸ”’

write_impl_section_heading πŸ”’

write_section_heading πŸ”’