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

Add multiple programming language support to class reference #40613

Merged
merged 1 commit into from
Jul 31, 2020

Conversation

HaSa1002
Copy link
Contributor

@HaSa1002 HaSa1002 commented Jul 22, 2020

This adds the possibility to write examples in the class reference in C# and GDScript. It is actually a sideeffect of the wanted effect of having a possiblity to collapse the examples in the documentation. (See godotengine/godot-docs#3824)
The current behaviour is untouched. So using [codeblock] ... [/codeblock] behaves as it did before.
However, I made it possible to do the following:

[codeblocks]
[gdscript]
var can_shoot2 = true
[/gdscript]
[csharp]
bool can_shoot2 = true;
[/csharp]
[/codeblocks]

In the online class reference will that be rendered as:
Online

text_editor/help/class_reference_examples: GDScript
grafik

text_editor/help/class_reference_examples: C#
grafik

text_editor/help/class_reference_examples: GDScript and C#
grafik

It would be nice, if the [gdscript] and [csharp] tags could be used outside of codeblocks, but this will break the online reference. I will see if I find a way to set the programming language globally in the online class reference too. This would be useful to state binding specific differences which are currently here. Nonetheless that is probably a different PR.

I will start adding examples to the class reference once verified.
I remember having read about this feature somewhere and reduz stated that in IRC.

@HaSa1002 HaSa1002 requested a review from a team as a code owner July 22, 2020 21:04
@YeldhamDev
Copy link
Member

Does this take into account Godot versions without C#?

@HaSa1002
Copy link
Contributor Author

Currently it always writes both.

@YeldhamDev
Copy link
Member

This will create unnecessary clutter for those who just use the GDScript version.

Is there some way to hide it from the in-editor docs? You could try checking for the existence of the GodotSharp singleton, like it's done here: https://github.com/godotengine/godot/pull/23522/files#diff-37015c74315fe579c5b4a6d43e73bcadR380

@HaSa1002
Copy link
Contributor Author

Isn't there a DEFINE for C# Support? If so, we could compile it conditionally. On the other hand, it might be overkill...

@YeldhamDev
Copy link
Member

Isn't there a DEFINE for C# Support?

None that I'm aware.

@HaSa1002
Copy link
Contributor Author

I will see. I have to do some fixup either way. The static checks aren't happy with me :)

@HaSa1002 HaSa1002 force-pushed the multi-lang-docs branch 2 times, most recently from 0c79af2 to 5ac418e Compare July 22, 2020 22:31
@HaSa1002
Copy link
Contributor Author

@YeldhamDev fixed the clutter for non C# users. For C# users I still include both, because they can also use GDScript. As clayjohn stated on IRC, we should somehow add an option to chose which language is shown. Sadly this is easier said than done.

@akien-mga
Copy link
Member

akien-mga commented Jul 23, 2020

There's a MODULE_MONO_ENABLED define (defined in modules/module_defines.gen.h or similar).

But more than hardcoding this in editor code, it would be better to query the available script languages drop the engine to see which are included in the build.

It could additionally be made configurable via an editor setting whether you want to see GDScript, C# (when available), or all.

I'd also make the tags more explicit: [gdscript] and [csharp].

@HaSa1002
Copy link
Contributor Author

Ok, I will add the editor option then. I have an idea for the the method names as well. Yeah the tags are a bit hacky, since I have to replace them with codeblock for the RTL :D. Will change their names too.

@HaSa1002
Copy link
Contributor Author

HaSa1002 commented Jul 23, 2020

@akien-mga Should I include the changed class doc xml as well? It's the one I used for testing, but done.

@HaSa1002
Copy link
Contributor Author

HaSa1002 commented Jul 23, 2020

Okay. I added two editor settings. One for making the class reference PascalCase (only the names of the DocData) and the other to select which examples should be shown. Options are GDScript, C#, and GDScript and C#.

@HaSa1002 HaSa1002 force-pushed the multi-lang-docs branch 2 times, most recently from c477137 to 7d3a043 Compare July 23, 2020 09:52
@HaSa1002
Copy link
Contributor Author

Fixed setter and getter methods not beeing pascal cased. I think it is pretty much done

@HaSa1002 HaSa1002 changed the title Add multiple programming language support in class reference Add multiple programming language support to class reference Jul 23, 2020
@akien-mga
Copy link
Member

One for making the class reference PascalCase (only the names of the DocData)

That should be in a separate PR (possibly proposal), there's a lot more involved than a simple snake_case to PascalCase conversion to provide a proper class reference for C#. Doing it only half-way is worse than not having the conversion IMO.

@HaSa1002
Copy link
Contributor Author

Will do.

@HaSa1002
Copy link
Contributor Author

Forgot the done. :) Moved the PascalCase into a seperate PR

@akien-mga akien-mga merged commit 5d880bf into godotengine:master Jul 31, 2020
@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga added the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Jul 31, 2020
HaSa1002 added a commit to HaSa1002/godot-docs that referenced this pull request Sep 4, 2020
@akien-mga akien-mga removed the cherrypick:3.x Considered for cherry-picking into a future 3.x release label Oct 5, 2021
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.

5 participants