mozilla/rust — Issue #1942: Parse rustdocs out of markdown-formatted doc strings
Author: brson
Created: 2012-03-07 23:23:20+00:00
State: open
Labels: A-rustdoc, I-enhancement

This is an example of a current rustdoc from core:

```
#[doc(
desc = "

Convert a string to a float

This function accepts strings such as

* '3.14'
* '+3.14', equivalent to '3.14'
* '-3.14'
* '2.5E10', or equivalently, '2.5e10'
* '2.5E-10'
* '', or, equivalently, '.' (understood as 0)
* '5.'
* '.5', or, equivalently, '0.5'

Leading and trailing whitespace are ignored.

",
args(
num = "A string"
),
return = "

none if the string did not represent a valid number. Otherwise, some(n) where
n is the floating-point number represented by [num].

")]
```

All of the extra attribute stuff is noise. Without much difficulty we could parse markdown like:

```
#[doc = "

Convert a string to a float

This function accepts strings such as

* '3.14'
* '+3.14', equivalent to '3.14'
* '-3.14'
* '2.5E10', or equivalently, '2.5e10'
* '2.5E-10'
* '', or, equivalently, '.' (understood as 0)
* '5.'
* '.5', or, equivalently, '0.5'

Leading and trailing whitespace are ignored.

Arguments:

* num - A string

Returns:

none if the string did not represent a valid number. Otherwise, some(n) where
n is the floating-point number represented by [num].

"]
```