Skip to content
This repository was archived by the owner on Aug 3, 2024. It is now read-only.

Add markup support for tables #577

Closed
wants to merge 8 commits into from
Closed

Conversation

potomak
Copy link

@potomak potomak commented Feb 17, 2017

Tables are composed by an optional header and body. The header is
composed by a single row. The body is composed by a non-empty list of
rows.

Example table with header:

+------+--------------+------------------------------------------+
| code | message      | description                              |
+======+==============+==========================================+
| 200  |   @OK@       | operation successful                     |
+------+--------------+------------------------------------------+
| 204  | @No Content@ | operation successful, no body returned   |
+------+--------------+------------------------------------------+

Example table without header:

+------+--------------+------------------------------------------+
| 200  |   @OK@       | operation successful                     |
+------+--------------+------------------------------------------+
| 204  | @No Content@ | operation successful, no body returned   |
+------+--------------+------------------------------------------+
| 404  | @Not Found@  | resource not found                       |
+------+--------------+------------------------------------------+

Example doc page (Classic theme):

Example doc page (Classic theme)

Example doc page (Ocean theme):

Example doc page (Ocean theme)

See #530.

Copy link

@epsilonhalbe epsilonhalbe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am certainly no expert on haddock, but looks good to me on a first glance

table :: Maybe [DocH () a] -> [[DocH () a]] -> Doc a
table header rows = DocTable (Table header rows)

it "parses a table with an header" $
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a header

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed(up).

Tables are composed by an optional header and body. The header is
composed by a single row. The body is composed by a non-empty list of
rows.

Example table with header:

    +----------+----------+
    | /32bit/  |   64bit  |
    +==========+==========+
    |  0x0000  | @0x0000@ |
    +----------+----------+

See haskell#530
@ranjitjhala
Copy link

👍

@TikhonJelvis
Copy link

I've definitely used lists where I wanted tables in my docs. This is a real improvement: looks good in the source and looks great when rendered.

Worth noting that Emacs, at least, supports editing this style of table.

@ivan-m
Copy link

ivan-m commented Feb 20, 2017

At the risk of bikeshedding, will other forms of table be supported?

This seems to copy what Pandoc calls "grid tables", but my general preference is for what it refers to as "pipe tables" (in part because I've tried editing this style of table in Emacs as @TikhonJelvis points out but found it very slow, but pipe-tables with orgtbl-mode worked very nicely).

@mpickering
Copy link
Collaborator

I don't think this is properly specified yet and the tests don't look very comprehensive.

@potomak
Copy link
Author

potomak commented Feb 20, 2017

@mpickering can you give me more info about what is it missing to be properly specified?

@potomak
Copy link
Author

potomak commented Feb 20, 2017

@TikhonJelvis a note: the parser, the way it's been implemented, doesn't support table elements on multiple lines.

@potomak
Copy link
Author

potomak commented Feb 20, 2017

@ivan-m I followed the proposal in #530, I don't have a strong opinion on the table format to support.

@potomak
Copy link
Author

potomak commented Mar 19, 2017

@bgamari you seem quite active on this repo, what do you think about this change?
Do you think I should just close this PR?
Do you have any suggestion how can I make progress on this?

@alexbiehl
Copy link
Member

alexbiehl commented Mar 20, 2017

@potomak Don't close this PR. Tables are a useful feature and we want it!

Maybe @mpickering can clarify his concerns so they can be addressed.

@alexbiehl
Copy link
Member

@potomak I see there is no documentation at all. I think it would help to add a few sentences to doc/markup.rst. I am sure this will get us half-way there.

@potomak
Copy link
Author

potomak commented Mar 20, 2017

@alexbiehl great! Thanks for the suggestion. I will update the documentation. I'm also working on a second version of this PR, it uses a different approach at table parsing. I will the PR soon.

parseTableContent :: Parser [[DocH mod Identifier]]
parseTableContent = many1 (parseTableRow <* parseTableRowDivider)

parseTableRow :: Parser [DocH mod Identifier]
Copy link
Member

@alexbiehl alexbiehl Mar 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should provide some way to escape | in table cells. Otherwise typing | results in odd parser errors.

@alexbiehl
Copy link
Member

@potomak what is the status on this one? Do you need any help/advice on moving this forward?

@hvr
Copy link
Member

hvr commented Aug 8, 2017

@potomak you mentioned a 2nd version of this PR; what's the status on that? and why did you think a different version was needed?

phadej added a commit to phadej/haddock that referenced this pull request Dec 24, 2017
Simple parser is done by Giovanni Cappellotto (@potomak)
in haskell#577
It seems to support single fine full tables, so far from full
RST-grid tables, but it's good start.

Table type support row- and colspans, but obviously parser is lacking.

Still TODO:
- Latex backend. Should we use multirow package
  https://ctan.org/pkg/multirow?lang=en?
- Hoogle backend: ?
@phadej phadej mentioned this pull request Dec 25, 2017
alexbiehl pushed a commit that referenced this pull request Dec 26, 2017
* Add table examples

* Add table types and adopt simple parser

Simple parser is done by Giovanni Cappellotto (@potomak)
in #577
It seems to support single fine full tables, so far from full
RST-grid tables, but it's good start.

Table type support row- and colspans, but obviously parser is lacking.

Still TODO:
- Latex backend. Should we use multirow package
  https://ctan.org/pkg/multirow?lang=en?
- Hoogle backend: ?

* Implement grid-tables

* Refactor table parser

* Add two ill-examples

* Update CHANGES.md

* Basic documentation for tables

* Fix documentation example
@alexbiehl
Copy link
Member

This has been addressed in another pr.

@alexbiehl alexbiehl closed this Dec 27, 2017
alexbiehl pushed a commit to alexbiehl/haddock that referenced this pull request Feb 1, 2018
* Add table examples

* Add table types and adopt simple parser

Simple parser is done by Giovanni Cappellotto (@potomak)
in haskell#577
It seems to support single fine full tables, so far from full
RST-grid tables, but it's good start.

Table type support row- and colspans, but obviously parser is lacking.

Still TODO:
- Latex backend. Should we use multirow package
  https://ctan.org/pkg/multirow?lang=en?
- Hoogle backend: ?

* Implement grid-tables

* Refactor table parser

* Add two ill-examples

* Update CHANGES.md

* Basic documentation for tables

* Fix documentation example
alexbiehl pushed a commit that referenced this pull request Feb 1, 2018
* Add table examples

* Add table types and adopt simple parser

Simple parser is done by Giovanni Cappellotto (@potomak)
in #577
It seems to support single fine full tables, so far from full
RST-grid tables, but it's good start.

Table type support row- and colspans, but obviously parser is lacking.

Still TODO:
- Latex backend. Should we use multirow package
  https://ctan.org/pkg/multirow?lang=en?
- Hoogle backend: ?

* Implement grid-tables

* Refactor table parser

* Add two ill-examples

* Update CHANGES.md

* Basic documentation for tables

* Fix documentation example
sjakobi pushed a commit to sjakobi/haddock that referenced this pull request Jun 10, 2018
* Add table examples

* Add table types and adopt simple parser

Simple parser is done by Giovanni Cappellotto (@potomak)
in haskell#577
It seems to support single fine full tables, so far from full
RST-grid tables, but it's good start.

Table type support row- and colspans, but obviously parser is lacking.

Still TODO:
- Latex backend. Should we use multirow package
  https://ctan.org/pkg/multirow?lang=en?
- Hoogle backend: ?

* Implement grid-tables

* Refactor table parser

* Add two ill-examples

* Update CHANGES.md

* Basic documentation for tables

* Fix documentation example

(cherry picked from commit 088b199)
hubot pushed a commit to ghc/ghc that referenced this pull request May 17, 2024
* Add table examples

* Add table types and adopt simple parser

Simple parser is done by Giovanni Cappellotto (@potomak)
in haskell/haddock#577
It seems to support single fine full tables, so far from full
RST-grid tables, but it's good start.

Table type support row- and colspans, but obviously parser is lacking.

Still TODO:
- Latex backend. Should we use multirow package
  https://ctan.org/pkg/multirow?lang=en?
- Hoogle backend: ?

* Implement grid-tables

* Refactor table parser

* Add two ill-examples

* Update CHANGES.md

* Basic documentation for tables

* Fix documentation example
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants