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

Insert a newline for empty single-line documentation comments #917

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

maffeus
Copy link

@maffeus maffeus commented Jan 29, 2025

This PR makes empty single-line documentation comments act as newlines.
This change fixes #905 and aligns single-line comments with multi-line comments, making them essentially equivalent as far as I can tell.

--- @class MyClass
---
--- A sample class.
local MyClass = {}
MyClass.__index = MyClass

image

--[=[
	@class MyClass

	A sample class.
]=]
local MyClass = {}
MyClass.__index = MyClass

image

@JohnnyMorganz
Copy link
Owner

Thanks for this! Can you also add a test case to Documentation.test.cpp?

@JohnnyMorganz
Copy link
Owner

Whoops, wrong button

@JohnnyMorganz JohnnyMorganz reopened this Feb 1, 2025
@maffeus
Copy link
Author

maffeus commented Feb 1, 2025

I'm not sure if this is the best way to add a test like this, because I feel like this is a much more complicated and nuanced test. Probably what would need to happen is every use of multiline comments (or vice versa) in Documentation.test.cpp should be replaced with a use of both (?) and check if their results are equal, but that just seems terrible to implement, and I'm not going to change the entire codebase for just that. 😓

Ideally, the end goal should probably always be congruence between multiline and single-line doc comments, such that someone could replace the --- with tabs, and add the --[=[ prefix and ]=] suffix and be left with the same rendered result no matter what. I'm just not sure how you would test such a thing without just testing both multiline and single-line doc comments for every test case.

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

Successfully merging this pull request may close these issues.

Single-line comments don't add newlines
2 participants