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

Styleguide First Pass #68

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

JustinWinningham
Copy link

First pass at styleguide for C# documentation

First pass at styleguide for C# documentation
@strlngd strlngd self-assigned this Apr 22, 2020
@strlngd
Copy link
Member

strlngd commented Apr 22, 2020

Very cool! The documentation definitely needs a more consistent format. I would also like to contribute towards this when I have the time (~2 days).

A few things to note:

  • Please convert all instances of <span style= "font-size:12px"> encasing the tables with a div. Using span in this specific way will result in a compilation error.

  • I have hosted this on the website here. Hopefully this will help with formatting and styling the above guide.

@strlngd strlngd linked an issue Apr 22, 2020 that may be closed by this pull request
STYLEGUIDE.md Outdated
|
</span>

> Omit elements entirely if not relavent to that class (eg: parent class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why that? Parent class and interfaces - usefull information.

Copy link
Author

Choose a reason for hiding this comment

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

removed.

* Type (with link to that object or objects)
* Notes

## Variables
Copy link
Contributor

Choose a reason for hiding this comment

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

Where to describe consts?
in this section, or another?

Copy link
Author

Choose a reason for hiding this comment

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

fixed :)

Fixed some typos, cleaned up the tables, and changed spans to divs per feedback request. Removed some overly strict requirements too.
Adjusted Class variables table to add row for const / read only / static / etc
Fixed broken Method Table
More Fixes
Last set of fixes, removed extra table columns and more cleanup
@JustinWinningham
Copy link
Author

Ready for Re-review :)

STYLEGUIDE.md Outdated
Comment on lines 91 to 99
<span style= "font-size:12px">

Using / Namespaces | | <span style='color:yellow'>Taleworlds.Core</span>| | | | <span style='color:green'>Saveable</span> |
:---|---|---|---|---|---|---:|
[System](EXAMPLE) | | | | | | 10000 |
[System.Xml](EXAMPLE)|
[TaleWorlds.SaveSystem](EXAMPLE) |
|
</span>
Copy link
Contributor

Choose a reason for hiding this comment

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

Is that table correct?
It render as:
изображение
But it make no sense..

Copy link
Author

Choose a reason for hiding this comment

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

The left column shows all the includes, the yellow is the specific namespace, and savable is green, the savable class number is 10000. I'm more than open to better recommendations

Copy link
Contributor

Choose a reason for hiding this comment

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

Table should contain similar data. But without table it will be over wide.
So, maybe table is the best now.


# Enums

Enums should be placed in their own file at the Class level (on their own page under a package) with the following format:
Copy link
Contributor

@Anakael Anakael Apr 22, 2020

Choose a reason for hiding this comment

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

Where to describe enums, which defined in class? In separate file? In that case info about using is redundant.

Copy link
Author

Choose a reason for hiding this comment

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

I was basing off of the decompiled dlls. Enums are defined in their and don't have anything else in them afaik:

public enum WeaponClass
{
// Token: 0x040005BF RID: 1471
Undefined,
// Token: 0x040005C0 RID: 1472
Dagger,
...

Copy link
Contributor

Choose a reason for hiding this comment

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

I am working on Hero class. And it define structs and enums in self.
Where would be good place to document them?

Copy link
Author

Choose a reason for hiding this comment

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

If they are unique / private to the class they should probably go somewhere within the class, if they live outside the class then they should go as their own page in the Enums section. Open to recommendations for the former.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok. I will place it to class on my case.
But according to styleguides enum should be separated from class.
So that lack on develop side :D (also with public variables)

STYLEGUIDE.md Outdated
|
</span>

### Values
Copy link
Contributor

Choose a reason for hiding this comment

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

Where H2 header?

Copy link
Author

Choose a reason for hiding this comment

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

fixed to H2


Unlike the root and package level READMEs, the class README will contain more than just links to child folders. Each class will start with a **Class Overview Panel**:

### [Parent Object Name](EXAMPLE)
Copy link
Contributor

@Anakael Anakael Apr 22, 2020

Choose a reason for hiding this comment

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

File should start with H1 header.
I suggest move info about parent and interfaces to H2 after description.

Copy link
Author

Choose a reason for hiding this comment

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

I'd argue its good to have quick access to the parrent class right next to the classname, but thats just me.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, it's good. So that's why I suggested h2 after description.

But when you open a class readme - you, most likely want to read about this certain class first, not related.

STYLEGUIDE.md Outdated
|...|...|...|...|
</div>

Methods should follow parameters, seperated by a H1 header.
Copy link
Contributor

Choose a reason for hiding this comment

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

-> H1
Is typo here?

Copy link
Author

Choose a reason for hiding this comment

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

fixed to be H2. Poor wording on my part. The idea is to have a clear break between each section

STYLEGUIDE.md Outdated

<div style= "font-size:12px">

| Type | Method Name | Number of Params |
Copy link
Contributor

Choose a reason for hiding this comment

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

Number of Params - redundant?

Copy link
Contributor

Choose a reason for hiding this comment

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

Params better, I think.

Copy link
Author

Choose a reason for hiding this comment

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

Agreed. Overthought it while writing. Fixed.

STYLEGUIDE.md Outdated
### [Parent Object Name](EXAMPLE)
## Method Name

| Parameters | Type | default | Optional? |
Copy link
Contributor

Choose a reason for hiding this comment

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

MnB2 use C#, not TS. Type -> Parameters is better :)
Methods discription place in separate file, do I understand correctly?
In that case we don't need table here, because we have almost the same in another place. In addition, discription would be better placed here, not in another header.
Example: https://docs.python.org/3/library/math.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, Optional and default have the same meaning.

Copy link
Author

Choose a reason for hiding this comment

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

oof. Not a C# master by any means, Fixed.

Copy link
Author

Choose a reason for hiding this comment

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

Each file (Classes, Methods, etc) will focus on itself. So the Methods will have their description in their own file, not in their class file. I agree that this table could be optional, but users may navigate straight to a method from very far away (so to speak) in the documentation and won't arrive by going directly through their parrent class (or struct, w/e) tree. If you think this is still worth removing after that consideration, I'll remove.

Copy link
Contributor

Choose a reason for hiding this comment

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

To summarize, I suggest:
Put methods declaration in class (when I read about class, I want to see it interface) as list (not table, because table assume that datas similar by size)
Put methods definition in separate file (without table).
In that case class won't be overwhelmed and definition won't be stretched out.

Lots of feedback fixes from Anakael's feedback
@strlngd strlngd removed a link to an issue Apr 23, 2020
@strlngd strlngd linked an issue Apr 23, 2020 that may be closed by this pull request
@strlngd
Copy link
Member

strlngd commented Apr 23, 2020

For this Style Guide, are you proposing that the C# API should include the namespace in each path? In other words, something like:

C# API > Library > Namespace > Class

Right now it is organized like this:

C# API > Library > Class

My vote is to stick with the current setup and then include the namespace at the top of the documentation for each class. Let me know your thoughts.

Also, I would rename instances of Package to Library/Namespace depending on the context.

@JustinWinningham
Copy link
Author

C# API > Library (by dll package) > Class > Method As for renaming package to library / namespace, im fine with either.


The above would be a valid snippet for the ```InformationMessage``` Class, but can be longer if the extra length is used to give important context about the snippet.

Directly after this intro snippet, we have a section outlining the variables of the class. All variables are assumed to have private setters unless otherwise noted. Each variable should contain all of the following information:
Copy link
Contributor

Choose a reason for hiding this comment

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

If it private - why it is required to be mentioned?

The above would be a valid snippet for the ```InformationMessage``` Class, but can be longer if the extra length is used to give important context about the snippet.

Directly after this intro snippet, we have a section outlining the variables of the class. All variables are assumed to have private setters unless otherwise noted. Each variable should contain all of the following information:

Copy link
Contributor

Choose a reason for hiding this comment

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

Mod?

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.

Documentation - Style Guide
4 participants