Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: Insert doc comments from .pest file to the Rule struct. #748

Closed
KSXGitHub opened this issue Dec 10, 2022 · 0 comments · Fixed by #765
Closed

Request: Insert doc comments from .pest file to the Rule struct. #748

KSXGitHub opened this issue Dec 10, 2022 · 0 comments · Fixed by #765

Comments

@KSXGitHub
Copy link

It would be incredibly helpful if the Rule struct and its variants have documentation to assist user.

Example

//! Documentation of the Rule struct itself.

/// Documentation of the `my_rule` variant.
my_rule - { ... }

should generate:

/// Documentation of the Rule struct itself.
enum Rule {
    /// Documentation of the `my_rule` variant.
    my_rule,
}
@KSXGitHub KSXGitHub added the bug label Dec 10, 2022
huacnlee added a commit to huacnlee/pest that referenced this issue Jan 9, 2023
Resolve pest-parser#748

For example:

```rust
//! A parser for JSON file.

/// Matches object, e.g.: `{ "foo": "bar" }`
object = { "{" ~ pair ~ ("," ~ pair)* ~ "}" | "{" ~ "}" }
```

should generate:

```rust
/// A parser for JSON file.
enum Rule {
    /// Matches object, e.g.: `{ "foo": "bar" }`
    object,
}
```
huacnlee added a commit to huacnlee/pest that referenced this issue Jan 9, 2023
Resolve pest-parser#748

For example:

```rust
//! A parser for JSON file.

/// Matches object, e.g.: `{ "foo": "bar" }`
object = { "{" ~ pair ~ ("," ~ pair)* ~ "}" | "{" ~ "}" }
```

should generate:

```rust
/// A parser for JSON file.
enum Rule {
    /// Matches object, e.g.: `{ "foo": "bar" }`
    object,
}
```
huacnlee added a commit to huacnlee/pest that referenced this issue Jan 18, 2023
Resolve pest-parser#748

For example:

```rust
//! A parser for JSON file.

/// Matches object, e.g.: `{ "foo": "bar" }`
object = { "{" ~ pair ~ ("," ~ pair)* ~ "}" | "{" ~ "}" }
```

should generate:

```rust
/// A parser for JSON file.
enum Rule {
    /// Matches object, e.g.: `{ "foo": "bar" }`
    object,
}
```
tomtau pushed a commit that referenced this issue Jan 18, 2023
…765)

* Add to support `///` and `//!` syntax for add doc comment for rules.

Resolve #748

For example:

```rust
//! A parser for JSON file.

/// Matches object, e.g.: `{ "foo": "bar" }`
object = { "{" ~ pair ~ ("," ~ pair)* ~ "}" | "{" ~ "}" }
```

should generate:

```rust
/// A parser for JSON file.
enum Rule {
    /// Matches object, e.g.: `{ "foo": "bar" }`
    object,
}
```

* Rewrite line_doc extract in pest_generator, avoid change AST.

* Improve grammar_doc, line_doc parse for keep whitespaces in head and tail.

* Rewrite line_docs generator by use HashMap with rule_name.

* Move DocComment methods into docs.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants