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

Fix ToRdoc generating incorrect {label,name}-lists #1093

Merged
merged 1 commit into from
Mar 9, 2024

Commits on Mar 6, 2024

  1. Fix ToRdoc generating incorrect {label,name}-lists

    Previously, trying to round-trip label-list and name-lists with the
    ToRdoc converter was not possible:
    
    ```ruby
    doc = <<~RDOC
    foo ::
    bar ::
      hi
    RDOC
    
    markup = RDoc::Markup.parse(doc)
    markup # => [doc: [list: NOTE [item: ["foo ", "bar"]; [para: "hi"]]]]
    
    rt = RDoc::Markup::ToRdoc.new.convert(markup)
    rt # => "foo\nbar:\n  hi\n\n"
    
    rt_markup = RDoc::Markup.parse(rt)
    rt_markup # => [doc: [para: "foo ", "bar:"], [verb: "hi\n"]]
    ```
    
    This commit addresses the issue by fixing ToRdoc to generate output that
    can be properly reparsed by RDoc. ToRdoc tests additionally needed to be
    updated for the new output.
    
    The old implementation of `accept_list_item_start` was copied to ToBs
    because those tests did not pass with the new changes and I am
    unfamiliar with the `backspace` format.
    
    After:
    
    ```ruby
    doc = <<~RDOC
    foo ::
    bar ::
      hi
    RDOC
    
    markup = RDoc::Markup.parse(doc)
    markup # => [doc: [list: NOTE [item: ["foo ", "bar"]; [para: "hi"]]]]
    
    rt = RDoc::Markup::ToRdoc.new.convert(markup)
    rt # => "foo::\nbar::\n  hi\n\n"
    
    rt_markup = RDoc::Markup.parse(rt)
    rt_markup # => [doc: [list: NOTE [item: ["foo", "bar"]; [para: "hi"], blankline]]]
    ```
    skipkayhil committed Mar 6, 2024
    Configuration menu
    Copy the full SHA
    c6c51aa View commit details
    Browse the repository at this point in the history