rust-embedded / rust-embedded/svd2rust

Whitespace in SVD files is lost

Open
#858 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
857
Forks
164
PR merge metrics
No merged PRs in 30d

Description

Raspberry Pi provide SVD files with descriptions like:

        <description>DW_apb_i2c address block

            List of configuration constants for the Synopsys I2C hardware (you may see references to these in I2C register header; these are *fixed* values, set at hardware design time):

            IC_ULTRA_FAST_MODE ................ 0x0 
            IC_UFM_TBUF_CNT_DEFAULT ........... 0x8 
(etc)
        </description>

It comes out in the Rust code as:

#[doc = "DW_apb_i2c address block List of configuration constants for the Synopsys I2C hardware (you may see references to these in I2C register header; these are *fixed* values, set at hardware design time): IC_ULTRA_FAST_MODE ....."]

I suspect this is because whitespace in XML is collapsed - any run of whitespace is converted into a single space character.

I tried putting the description in a <![CDATA[ ]> block, but a) svdtools removed it and b) even if I force it back it, svd2rust ignores it.

How can I try and make sure the whitespace in the description is carried through into the docs? In particular, I want to avoid very very very long single line descriptions appearing in https://docs.rs/rp235x-pac/latest/rp235x_pac/index.html

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the Raspberry Pi SVD description case and inspecting the generated Rust documentation output; the issue does not name source files or tests. Trace where description text is parsed and emitted, then verify that line breaks and meaningful indentation are preserved so the generated docs do not contain very long single-line descriptions.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
embedded-iot, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.