rdoc icon indicating copy to clipboard operation
rdoc copied to clipboard

Standardize table and heading markup elements

Open vinistock opened this issue 7 months ago • 1 comments

I noticed that Markup elements are currently not standardized in any way - even though the code does make some assumptions.

For example, there are visitors that depend on all elements implementing accept, but no parent class or interface that will help guarantee every element implements it. Some elements are implemented as structs, while other are classes. Some have parent classes for shared functionality and APIs and others don't.

I propose that we standardize the markup elements a bit more, so that we can have a common interface for them. It will make it easier for the RDoc to Markdown translator if we can enforce that every markup element has to be able to print itself in Markdown - and I believe the code will be easier to understand too.

This PR creates a base Markup::Element class and I standardized Heading and Table as an example. I'm also finding it challenging to understand the logic with no clue about what types are and what is expected from each method, so I also propose we annotate some of these as documentation - even if we're not adopting type checking.

If folks agree, I will continue to standardize more markup elements. I'm trying to document what each element represents along the way.

vinistock avatar Jul 12 '25 15:07 vinistock

🚀 Preview deployment available at: https://b240492a.rdoc-6cd.pages.dev (commit: eb1eaccf25f4d06026b46a9f20717eabd5b941c2)

matzbot avatar Jul 12 '25 15:07 matzbot

how is this base class compared to RDoc::Markup::Raw

Raw will also inherit from Element as it represents an element that gets inserted with no modifications in the document.

it may be worth to create a list of elements to update to parallelize/track the work?

I can put it in an issue if you'd like. My understanding is that it would be everything under lib/rdoc/markup.

vinistock avatar Dec 24 '25 13:12 vinistock