Skip to content

Website documentation generation clobbers indentation for config docs #15057

@connorshea

Description

@connorshea

For example with code like this in #15054:

#[derive(Debug, Clone, JsonSchema)]
#[serde(rename_all = "camelCase", default)]
pub struct NoUselessComputedKey {
    /// The `enforceForClassMembers` option controls whether the rule applies to
    /// class members (methods and properties).
    ///
    /// Examples of **correct** code for this rule with the `{ "enforceForClassMembers": false }` option:
    /// ```js
    /// class SomeClass {
    ///     ["foo"] = "bar";
    ///     [42] = "baz";
    ///     get ['b']() {}
    ///     set ['c'](value) {}
    ///     static ["foo"] = "bar";
    /// }
    /// ```
    enforce_for_class_members: bool,
}

We end up with docs in the generated website with no indentation (the backslashes are added by me due to GitHub markdown not liking them):

## Configuration

This rule accepts a configuration object with the following properties:

### enforceForClassMembers

type: `boolean`

default: `true`

The `enforceForClassMembers` option controls whether the rule applies to
class members (methods and properties).

Examples of **correct** code for this rule with the `{ "enforceForClassMembers": false }` option:
\```js
class SomeClass {
["foo"] = "bar";
[42] = "baz";
get ['b']() {}
set ['c'](value) {}
static ["foo"] = "bar";
}
\```

Something with how the documentation is processed results in the indentation being stripped out of the generated HTML page.

Presumably a problem from this file:
https://github.com/oxc-project/oxc/blob/6faa11d73cbe58c33941acbfef3c6940a696d572/tasks/website/src/linter/rules/doc_page.rs

Other examples:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions