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

Remove ditto and nodoc without colons #6362

Merged

Conversation

j8r
Copy link
Contributor

@j8r j8r commented Jul 10, 2018

We are used to choose :nodoc: with colons but ditto without.
However the other variant is also supported, nodoc and :ditto: could also be used.
Using colons shows that they are special semantics and not another comments.

Since # :nodoc: is always used vs. # nodoc, the diffs are mainly about changing # ditto to # :ditto:.

@RX14
Copy link
Contributor

RX14 commented Jul 10, 2018

My main concern is this breaking for people silently. Probably the best solution would be to compile-error "nodoc" or "ditto" comments to get people to change.

This wasn't broken before though, so I'm not sure we should really "fix" it.

@j8r
Copy link
Contributor Author

j8r commented Jul 11, 2018

There is likely not much people outside crystal-lang contributors using this undocumented feature @RX14 .

Besides that, in the worst case, nodoc and ditto will be shown as-is in the method description on the HTML doc – not a big deal.

@straight-shoota
Copy link
Member

straight-shoota commented Jul 11, 2018

If the behaviour of the compiler is changed, it should raise. I'm not sure this should to be changed at all (at least not right away).

I like changing from ditto to :ditto: in the stdlib docs, but it doesn't need to be enforced by the compiler/docs generator.

@RX14
Copy link
Contributor

RX14 commented Jul 12, 2018

@j8r "ditto" is documented, and plenty of people use it.

@straight-shoota
Copy link
Member

The reference should better use :ditto: though. But still, it doesn't hurt to support ditto as well.

@j8r
Copy link
Contributor Author

j8r commented Jul 12, 2018

I was searching in the code @RX14 - doesn't know it was here, my bad. Itmight also be in other places.

OK, for now we can print a warn about the deprecation of ditto and nodoc.

@j8r
Copy link
Contributor Author

j8r commented Jul 15, 2018

What to do to merge - do I need to add a deprecated notice, what's the standard way?

@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch from 48a0bdf to f442533 Compare July 24, 2018 22:09
@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch from f442533 to 3482d7c Compare July 25, 2018 08:19
@paulcsmith
Copy link
Contributor

I think that just like in other parts of Crystal, there should be one way to do things unless there is a benefit to having 2. Just like Crystal has fewer aliases than Ruby, I think making things consistent and making it only work with colons makes it easier to search for, easier to tell that it is "special", and simpler for codebases to have a common way of documenting things, since only one will work.

I like the idea of raising if the comment line contains just the word ditto or just the word nodoc without colons so that people know there was a change and can easily make that change (a find-and-replace would be really simple # nodoc -> # :nodoc:. Piece of cake)

@straight-shoota
Copy link
Member

Sounds good.

As an additional enhancement, I'd like that that a comment just has to start with :nodoc: but may contain other content. This allows to actually have documentation (in code) without being included in the public API.

@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch from 8f7f65b to 5880802 Compare September 3, 2018 16:15
@j8r
Copy link
Contributor Author

j8r commented Sep 3, 2018

Rebased to include the change of #6627 by @Sija, which addresses the @straight-shoota's comment above.

@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch from 5880802 to 40b7ec4 Compare September 3, 2018 19:55
@j8r
Copy link
Contributor Author

j8r commented Sep 22, 2018

What's remaining for merge, all's good?

@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch from 40b7ec4 to 162b06c Compare October 19, 2018 08:53
@j8r
Copy link
Contributor Author

j8r commented Oct 26, 2018

Can this PR be milestoned? This will avoid me to change the TODO: after x.x.x and rebase for each new release.

@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch 2 times, most recently from 23ea859 to 8c2735c Compare October 27, 2018 12:51
@straight-shoota
Copy link
Member

I'd prefer if this were two commits, one changing ditto to :ditto:, the other changing compiler behaviour. The first one could be merged right away. Maybe that would be a good idea to split the compiler change into a different PR. It feels like that part might need more discussion.

I think we all agree that using the variants with colons is the preferred way. Judging from the approving reactions, it seems also settled that support for non-colon variants should vanish.

It is however unclear if this should be silent, only a warning or a compiler error. And when it should be applied.

I don't like the current implementation, which just prints a message to STDOUT. Warnings tend to be ignored anyway. IIRC it was decided once that the compiler should either work or fail, but don't issue warnings.

I'd be fine with raising or failing silently. Raising for this seems a bit harsh, so I tend to prefer silently ignoring it. The costs of an error are pretty low: You'd have supposedly undocumented features show up in the API docs with a description nodoc, or some features documented as ditto. Both meanings can be expanded by the reader and are relatively easy to spot by maintainers. That's nothing worth raising for.

Maybe the docs generator could issue a warning and/or the formatter detect and adapt usages. The compiler would stop recognizing non-colon variants two releases later.

@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch 2 times, most recently from a9228e5 to d2b8ca3 Compare January 10, 2019 14:06
@j8r
Copy link
Contributor Author

j8r commented Jan 10, 2019

@straight-shoota that's fine that the compiler doesn't warn before 1.0 stable, but after the release I hope we'll got deprecation warning before having breaking changes like this (despite not-critical, this is only docs).

@j8r
Copy link
Contributor Author

j8r commented Jan 10, 2019

I've separated in two commits to follow the suggestion of @straight-shoota .
I let the core members deciding what to do next.

@asterite
Copy link
Member

@j8r we document them

@j8r
Copy link
Contributor Author

j8r commented Oct 29, 2019

Using something uncommon like colons directly show us that they are not regular comments.
Other symbols than colons could be used also.

@bcardiff
Copy link
Member

I like more the colon versions. But it's true that unless we validate/parse :<word>: are within the known doc special keywords both are equally (un)safe. The colon version has the change to implement that validation in the future at least.

@straight-shoota
Copy link
Member

straight-shoota commented Oct 29, 2019

@asterite I disagree. Using a special syntax highlights that this is a special value with special behaviour. It differentiates these values from regular text. When a method is documented by a single word, it might be confusing whether that is just a description or has some special meaning (is plain super a keyword, or previous?). When we use a specific format (such as wrapping a word in colons) we could even make any similar value that is not a defined keyword a failure.
:inherit: doesn't even need to be placed at the start of a doc comment, it can be surrounded by paragraphs (see #6989) and currently doesn't support the non-colon variant. Without colons this would be really hard to spot as a keyword.

Omitting the colons might not break anything, but IMO it doesn't improve either. It might be a matter of habit, but I like the :nodoc: notation. I'm pretty sure we had previous discussions about this and always preferred the colon variant.

We could possibly consider using a unique format for specifying doc options (see #8353). For example a syntax inspired by JavaDoc tags could work for this. But I think I'd still prefer colon delimited keywords for :nodoc:, :ditto: and :inherit: because they don't define metadata but directly alter the documentation text.

@j8r
Copy link
Contributor Author

j8r commented Oct 29, 2019

It may be a good idea @straight-shoota .
There are TODO:, NOTE:, we may also have DITTO and NODOC.
There is less noise, as @asterite pointed out, and there are still in highlighted from regular comments.

@asterite
Copy link
Member

Just for reference (I'm not saying it's a good or bad idea), I copied ditto from D: https://dlang.org/spec/ddoc.html#parsing

@straight-shoota
Copy link
Member

@asterite ditto alone might have been fine to use only the blank word because it is typically the only content of a doc comment. But nodoc can be followed by internal documentation. And finally inherit which can be somewhere inside the doc text. They definitely call for a special syntax to make them stand out.

@bcardiff
Copy link
Member

Let's keep using and encouraging :nodoc:, :ditto: and :inherit:. And eventually stop treating non-colon versions with a deprecation warning.

@j8r
Copy link
Contributor Author

j8r commented Nov 7, 2019

I just keep what I've done with sed -i -e 's/# ditto/# :ditto:/g' -e 's/# nodoc/# :nodoc:/g' $(find . -name "*.cr") - replacing all ditto/nodoc with :ditto:/:nodoc:.

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

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

When warnings are reported it should still work. I think the current state is that ditto emits a warning but is not treated as :ditto:

src/compiler/crystal/tools/doc/generator.cr Outdated Show resolved Hide resolved
src/compiler/crystal/semantic/top_level_visitor.cr Outdated Show resolved Hide resolved
Copy link
Member

@straight-shoota straight-shoota left a comment

Choose a reason for hiding this comment

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

It's fine to merge, but I have a (non-essential) suggestion.

@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch 2 times, most recently from 4393e22 to 0d8efa7 Compare December 30, 2019 13:24
@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch from 0d8efa7 to d7bc5f5 Compare January 11, 2020 20:46
@j8r j8r force-pushed the ditto_nodoc_only_with_colons branch from d7bc5f5 to 18998b0 Compare January 11, 2020 20:47
@j8r
Copy link
Contributor Author

j8r commented Jan 11, 2020

@RX14, remains your approval.

@straight-shoota straight-shoota merged commit 11a6f9a into crystal-lang:master Jan 12, 2020
@straight-shoota
Copy link
Member

Thanks @j8r

@straight-shoota straight-shoota added this to the 0.33.0 milestone Jan 12, 2020
@j8r j8r deleted the ditto_nodoc_only_with_colons branch January 12, 2020 22:31
@bcardiff bcardiff added topic:tools:docs-generator and removed pr:needs-work A PR requires modifications by the author. labels Jan 13, 2020
@bcardiff
Copy link
Member

FYI. I was checking how this was working and it neither outputs the warnings, nor the warning are build with location information to tell the user were to fix the nodoc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants