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 broken method and type headings in generated documentation #2262

Merged

Conversation

srenatus
Copy link
Contributor

@srenatus srenatus commented Oct 6, 2017

Before, many from() methods' docs were broken, because markdown
doesn't allow you to have line breaks in your headers, e.g.

### from[A: ((I8 val | I16 val | I32 val |
    [I64](builtin-I64) val | [I128](builtin-I128) val | [ILong](builtin-ILong) val |

Now, it'll not insert breaks for unions (introduced in #1294) when it is
a method header, but leaves it as one long line. (It certainly isn't
beautiful, but it is less broken...)

Turns out this bug has another instance in document headers:

# Flag\[A: (([U8](builtin-U8) val | [U16](builtin-U16) val | [U32](builtin-U32) val |
    [U64](builtin-U64) val | [U128](builtin-U128) val | [ULong](builtin-ULong) val |

...will also be one long line now.


Before:
screen shot 2017-10-06 at 08 07 19

After:
screen shot 2017-10-06 at 09 26 36

@@ -796,7 +796,7 @@ static void doc_entity(docgen_t* docgen, docgen_opt_t* docgen_opt, ast_t* ast)

// Now we can write the actual documentation for the entity
fprintf(docgen->type_file, "# %s", name);
doc_type_params(docgen, docgen_opt, tparams, true);
doc_type_params(docgen, docgen_opt, tparams, true, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

we need a false here, since those type params are part of a markdown heading

Copy link
Contributor

Choose a reason for hiding this comment

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

E.g. the title of the collections.Range docs is still line-broken

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right! This is a slightly different, but of course related, bug: I've just found an instance of it in the Flag docs.

Thanks, will update. 👍

Copy link
Contributor Author

@srenatus srenatus Oct 6, 2017

Choose a reason for hiding this comment

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

(Oh I should have reloaded my page -- didn't see your second comment when adding mine. Anyhow, you're right. It's updated.)

@srenatus srenatus force-pushed the docgen/no-line-breaks-for-headers branch from 85dea45 to 3fdc6ce Compare October 6, 2017 08:30
@@ -344,7 +344,7 @@ static const char* doc_get_cap(ast_t* cap)

// Write the given type to the current type file
static void doc_type(docgen_t* docgen, docgen_opt_t* docgen_opt,
ast_t* type, bool generate_links)
ast_t* type, bool generate_links, bool break_union_lines)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we want to rename this to break_linkes as it does not only apply to union types and would be more consistent with the existing functions.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

hmm yeah... it's a bit odd there. I initially only wanted it to apply to union, but then I've found that's getting threaded through the other types... so, yeah, where this ended up in, it makes more sense to call it break_lines.

@mfelsche
Copy link
Contributor

mfelsche commented Oct 6, 2017

Oh yeah! i came across this nuisance several times. Thank you for tackling this!

Before, many `from()` methods' docs were broken, because markdown
doesn't allow you to have line breaks in your headers, e.g.

    ### from[A: ((I8 val | I16 val | I32 val |
        [I64](builtin-I64) val | [I128](builtin-I128) val | [ILong](builtin-ILong) val |

Now, it'll not insert breaks for unions (introduced in ponylang#1294) when it is
a method header, but leaves it as one long line. (It certainly isn't
beautiful, but it is less broken...)

Turns out this bug has another instance in document headers:

    # Flag\[A: (([U8](builtin-U8) val | [U16](builtin-U16) val | [U32](builtin-U32) val |
        [U64](builtin-U64) val | [U128](builtin-U128) val | [ULong](builtin-ULong) val |

...will also be one long line now.

Also renames an existing `line_breaks` argument to `break_lines` to be
in-line with `generate_links`.

Signed-off-by: Stephan Renatus <[email protected]>
@srenatus srenatus force-pushed the docgen/no-line-breaks-for-headers branch from 3fdc6ce to e526c07 Compare October 6, 2017 09:08
@mfelsche mfelsche added the changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge label Oct 6, 2017
@mfelsche mfelsche changed the title docgen: don't break union types in headers Fix broken method and type headings in generated documentation Oct 6, 2017
@mfelsche
Copy link
Contributor

mfelsche commented Oct 6, 2017

@srenatus I added the "changelog - fixed" and edited the title for the changelog.

@mfelsche mfelsche merged commit 796848e into ponylang:master Oct 6, 2017
ponylang-main added a commit that referenced this pull request Oct 6, 2017
@mfelsche
Copy link
Contributor

mfelsche commented Oct 6, 2017

Thank you very much!

@srenatus srenatus deleted the docgen/no-line-breaks-for-headers branch October 6, 2017 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog - fixed Automatically add "Fixed" CHANGELOG entry on merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants