Closed tocic closed 2 weeks ago
I'm definitely for the ability to autoformat the code consistently (i.e. the presence of .clang-format
and a fixed version of clang-format
). Then the question is whether we want to provide this ability to submitters or only to mods/admins. If the former, I'd add a button to do just that (pressing it is optional and it's possible to continue manual formatting after the press). If the latter, maybe it's already good enough to just run clang-format
by hand and click on the existing "VIEW ON SITE" or "preview" buttons to see how it looks (but the new button would be handy anyway). So my main point is that the user who does the formatting should be able to see the end result before submitting/saving, not after.
I'm definitely for the ability to autoformat the code consistently (i.e. the presence of
.clang-format
and a fixed version ofclang-format
). Then the question is whether we want to provide this ability to submitters or only to mods/admins. If the former, I'd add a button to do just that (pressing it is optional and it's possible to continue manual formatting after the press). If the latter, maybe it's already good enough to just runclang-format
by hand and click on the existing "VIEW ON SITE" or "preview" buttons to see how it looks (but the new button would be handy anyway). So my main point is that the user who does the formatting should be able to see the end result before submitting/saving, not after.
Yeah that would be best. I've added https://github.com/knatten/cppquiz/issues/356, then we can get back to this later.
OK, let's merge the last 2 questions and I'll rebase this PR and write a comment.
OK, let's merge the last 2 questions and I'll rebase this PR and write a comment.
Good plan!
\<changes> — \<reason> — \<automatable>:
`` instead of
` for code blocks (even inside quotes) — easier to read/write, code highlighting — greppableusing namespace std;
— more vertical space — clang-tidy
/greppableclang-format
can consistently do the oppositeclang-format
(...)
for omitting, [some text]
for our remarks inside references — consistency — not*
/**
instead of _
/__
— consistency, to support _
in refs — nothttps
instead of http
— security — greppablegit
>
instead of ""
for refs — easier to read, better highlighting — not>
instead of just >
— consistency, easier to read — greppable>
(right angle bracket + newline) for linebreaks in quotes — vanilla markdown syntax, idk why it renders correctly without them — not¶note-X
and ¶general-example-Y
directly where appropriate — no need to write [*Note X*:
and — *end example*]
— not
Thanks for fixing this! I had an idea for how to auto format most of the code, without messing up manual formatting of questions like https://cppquiz.org/quiz/question/127. We could add an extra field
auto_format
to theQuestion
model, which if toggled, causes the code to run throughclang-format
on save. This should beFalse
by default to avoid to messing up manual formatting in the contribution form, but then mods could turn it on during review for most questions.clang-format
turns out to be installable throughpip
, which is very handy. We also need to create a.clang-format
file.What do you think? Should we turn the above into an issue? Or do you have any other ideas for how to solve this?