Guidedog 설명서 1.0.0-beta.16
언어
이 페이지의 내용
Guidedog / 문서 1.0.0-beta.16

guidedoc_defaults

The built-in pieces Guidedog assembles around the engine: the registry of readers and renderers (registry), typed read options for the built-in readers (rst_options, sphinx_options, myst_options), and the highlighters that connect gd-highlight to the renderers (HtmlHighlighter, TypstHighlighter).

let registry = guidedoc_defaults::registry();
let mut ws = guidedoc::Workspace::new();
let html = guidedoc::convert_text(&mut ws, &registry, "myst", "html", "# Hello\n");
assert!(html.expect("converts").contains("Hello"));

Structs

pub struct guidedoc_defaults::HtmlHighlighter

Highlights code blocks as the HTML Pygments writes for Sphinx, with its short CSS classes.

The language resolves as Sphinx resolves it: default is Python (or a Python console session), falling back to plain text when the code does not lex as Python; guess guesses; an unknown language is plain text, escaped as Pygments escapes it.

One value keeps a reusable buffer, so a renderer that highlights many blocks does not allocate per block. It is not Sync: give each rendering thread its own.

Implementations

impl HtmlHighlighter
pub fn new() -> HtmlHighlighter

Creates a highlighter with an empty buffer.

Trait Implementations

impl Highlighter for HtmlHighlighter
fn highlight(&self, language: &str, code: &str, out: &mut Emitter<'_>) -> bool
pub struct guidedoc_defaults::TypstHighlighter

Highlights code blocks as Typst data for the book template’s gd-highlight function, so books draw code with Guidedog’s colours rather than Typst’s.

It declines (returns false) plain text and languages it does not know, so the renderer keeps Typst’s own raw block for those. Like HtmlHighlighter, one value reuses its buffer and belongs to one thread.

Implementations

impl TypstHighlighter
pub fn new() -> TypstHighlighter

Creates a highlighter with an empty buffer.

Trait Implementations

impl Highlighter for TypstHighlighter
fn highlight(&self, language: &str, code: &str, out: &mut Emitter<'_>) -> bool
pub struct guidedoc_defaults::ReaderSettings

The settings of the built-in readers for converting one file, kept together so read options can borrow them: Docutils’ settings for rst, Sphinx’s for sphinx, and MyST with the Sphinx layer’s directives and roles for myst.

Fields

pub rst: guidedoc_rst::Settings

The rst reader’s settings.

pub sphinx: guidedoc_sphinx::Config

The sphinx reader’s configuration.

pub myst: guidedoc_commonmark::Settings

The myst reader’s settings, with the Sphinx layer as their extension.

Implementations

impl ReaderSettings
pub fn with_config(config: guidedoc_sphinx::Config) -> Self

Settings whose Sphinx layer (for sphinx and myst) uses config.

pub fn for_source() -> Self

Settings for writing source again (the rst renderer): no smart quotes, so the text keeps the quotes and dashes it was written with.

pub fn options(&self, reader: &str) -> ReadOptions<'_>

The read options for reader reader, borrowing these settings; other readers (commonmark) get the defaults.

Trait Implementations

impl Default for ReaderSettings
fn default() -> Self

The readers’ defaults; MyST reads {doc}, {ref} and directives as Sphinx does.

Functions

pub fn guidedoc_defaults::myst_options(settings: &guidedoc_commonmark::Settings) -> ReadOptions<'_>

Read options for the myst reader with settings (from guidedoc_commonmark::Settings::default() or guidedoc_sphinx::myst_settings); the options borrow the settings. The commonmark reader takes no settings.

pub fn guidedoc_defaults::registry() -> Registry

The built-in registry: readers rst, sphinx, commonmark (pure CommonMark 0.31.2) and myst (MyST Markdown); renderers html, typst (Typst source), text, and rst (reStructuredText).

Building it allocates two small vectors; keep one per program or thread and reuse it.

pub fn guidedoc_defaults::rst_options(settings: &guidedoc_rst::Settings) -> ReadOptions<'_>

Read options for the rst reader with settings (start from guidedoc_rst::default_settings()); the options borrow the settings.

Settings travel with their type, so another reader refuses them with core.read.settings_type instead of misreading them.

pub fn guidedoc_defaults::sphinx_options(config: &guidedoc_sphinx::Config) -> ReadOptions<'_>

Read options for the sphinx reader with config (start from guidedoc_sphinx::Config::default()); the options borrow the configuration.