Skip to content

Commit 89d2ec3

Browse files
authored
Merge pull request #3864 from thalbern/feature/doc_contribute
extended documentation guide with style guide / general information
2 parents 240063c + 3af5a6e commit 89d2ec3

File tree

6 files changed

+334
-192
lines changed

6 files changed

+334
-192
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ To get started, simply follow these steps
4747
4. Make **small and frequent** commits that include tests which could be a unity scene showing usage of your feature.
4848
5. Make sure that all the tests continue to pass.
4949
6. Follow the [Coding Guidelines](CodingGuidelines.md).
50-
7. Ensure the code and feature(s) are documented as described in the [Documentation Guidelines](DocumentationGuide.md).
50+
7. Ensure the code and feature(s) are documented as described in the [Documentation Guidelines](Documentation/DocumentationGuide.md).
5151
8. Ensure the code works as intended on all [platforms](#supported-platforms).
5252
- For Windows UWP projects, your code must be [WACK compliant](https://developer.microsoft.com/en-us/windows/develop/app-certification-kit). To do this, generate a Visual Studio solution, right click on project; Store -> Create App Packages. Follow the prompts and run WACK tests. Make sure they all succeed.
5353
9. Update the [documentation](#contributing) with additional information as needed.

Documentation/DevDocGuide.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Developer Documentation Guide
1+
# Developer portal generation guide
22

33
MRTK uses [docfx](https://dotnet.github.io/docfx/index.html) to generate html documentation out of triple slash comments in code and .md files in the MRTK repository. Docfx documentation generation is automatically triggered by CI (soon) on completed PRs in the mrtk_development branch.
44
The current state of the developer documentation can be found on the [MRTK github.io page](https://microsoft.github.io/MixedRealityToolkit-Unity/)
@@ -129,6 +129,7 @@ The versioning system can also be used for showing doc versions from other dev b
129129
* External crefs - As long as there's no xref service available (and listed in the docfx build file) crefs to external libraries won't work. If you still want to link to a specific external symbol that doesn't have xref service but an online api documentation you can use a href instead. Example: linking to EditorPrefs of Unity: <see href="https://docs.unity3d.com/ScriptReference/EditorPrefs.html">EditorPrefs</see>
130130

131131
## See also
132-
* [DocFX](https://dotnet.github.io/docfx/index.html)
132+
* [MRTK documentation guide](DocumentationGuide.md)
133133
* [MRTK developer documentation on github.io](https://microsoft.github.io/MixedRealityToolkit-Unity/)
134+
* [DocFX](https://dotnet.github.io/docfx/index.html)
134135

Documentation/DocsToDo.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
title: Documentation TODO list
3+
description:
4+
author:
5+
ms.author:
6+
ms.date:
7+
keywords:
8+
---
9+
10+
# Documentation TODO list
11+
Lines changed: 316 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,316 @@
1+
<img src="../External/ReadMeImages/MRTK_Logo_Rev.png">
2+
3+
# Documentation guidelines
4+
5+
This document outlines the documentation guidelines and standards for the Mixed Reality Toolkit (MRTK). It's purpose is to get you started quickly by giving an introduction about the technical aspects that you need to know, to point out common pitfalls and to describe the writing style that you should try to follow.
6+
7+
The page itself is supposed to serve as an example, therefore it uses the intended style and the most common markup features of the documentation.
8+
9+
Herein you will find some general style advice as well as the standards for the following forms of the MRTK documentation:
10+
11+
- [Source](#source-documentation)
12+
- [How-to](#how-to-documentation)
13+
- [Design](#design-documentation)
14+
- [Performance notes](#performance-notes)
15+
- [Breaking changes](#breaking-changes)
16+
17+
---
18+
19+
## Functionality and markup
20+
21+
This section describes frequently needed features. To see how they work, look at the source code of the page.
22+
23+
1. Numbered lists
24+
1. Nested numbered lists with at least 3 leading blank spaces
25+
1. The actual number in code is irrelevant; parsing will take care of setting the correct item number.
26+
* Bullet point lists
27+
* Nested bullet point lists
28+
* Text in **bold** with \*\*double asterisk\*\*
29+
* _italic_ *text* with \_underscore\_ or \*single asterisk\*
30+
* Text `highlighted as code` within a sentence \`using backquotes\`
31+
* Links to docs pages [MRTK documentation guidelines](DocumentationGuide.md)
32+
* Links to [anchors within a page](#style); anchors are formed by replacing spaces with dashes, and converting to lowercase
33+
34+
For code samples we use the blocks with three backticks \`\`\` and specify *csharp* as the language for syntax highlighting:
35+
36+
``` csharp
37+
int SampleFunction(int i)
38+
{
39+
return i + 42;
40+
}
41+
```
42+
43+
When mentioning code within a sentence `use a single backtick`.
44+
45+
### TODO comments
46+
47+
To mark areas in the documentation that need to be revisited later again, please use the following comment style, to make it easy to find those places again:
48+
49+
\<\!-- TODO: add more details --\>
50+
51+
Also consider adding pages with TODOs to the [documentation TODO list](DocsToDo.md).
52+
53+
54+
## Page layout
55+
56+
### Introduction
57+
58+
The part right after the main chapter title should serve as a short introduction what the chapter is about. Do not make this too long, instead add sub headlines. These allow to link to sections and can be saved as bookmarks.
59+
60+
### Main body
61+
62+
Use two-level and three-level headlines to structure the rest.
63+
64+
**Mini Sections**
65+
66+
Use a bold line of text for blocks that should stand out. We might replace this by four-level headlines at some point.
67+
68+
### 'See also' section
69+
70+
Most pages should end with a chapter called *See also*. This chapter is simply a bullet pointed list of links to pages related to this topic. These links may also appear within the page text where appropriate, but this is not required. Similarly, the page text may contain links to pages that are not related to the main topic, these should not be included in the *See also* list. See [this page's ''See also'' chapter](#see-also) as an example for the choice of links.
71+
72+
## Table of Contents (TOC)
73+
74+
Toc files are used for generating the navigation bars in the MRTK github.io documentation.
75+
Whenever you're adding a new file to the documentation make sure that there's an entry for that file in one of the toc.yml files of the documentation folder. Only articles listed in the toc files will show up in the navigation of the developer docs.
76+
There can be a toc file for every subfolder in the documentation folder which can be linked into any existing toc file to add it as a subsection to the corresponding part of the navigation.
77+
78+
## Style
79+
80+
### Writing style
81+
82+
General rule of thumb: Try to **sound professional**. That usually means to avoid a 'conversational tone'. Also try to avoid hyperbole and sensationalism.
83+
84+
1. Don't try to be (overly) funny.
85+
2. Never write 'I'
86+
3. Avoid 'we'. This can usually be rephrased easily, sometimes you can use 'MRTK' instead. Example: "we support this feature" -> "MRTK supports this feature" or "the following features are supported ...".
87+
4. Similarly, try to avoid 'you'. Example: "With this simple change your shader becomes configurable!" -> "Shaders can be made configurable with little effort."
88+
5. Do not use 'sloppy phrases'.
89+
6. Avoid sounding overly excited, we do not need to sell anything.
90+
7. Similarly, avoid being overly dramatic. Exclamation marks are rarely needed.
91+
92+
### Capitalization
93+
94+
* Use **Sentence case for headlines**. Ie. capitalize the first letter and names, but nothing else.
95+
* Use regular English for everything else. That means **do not capitalize arbitrary words**, even if they hold a special meaning in that context. Prefer *italic text*, if you really want to highlight certain words, [see below](#emphasis-and-highlighting).
96+
* When a link is embedded in a sentence (which is the preferred method), the standard chapter name always uses capital letters, thus breaking the rule of no arbitrary capitalization inside text. Therefore use a custom link name to fix the capitalization. As an example, here is a link to the [bounding box](README_BoundingBox.md) documentation.
97+
* Do capitalize names, such as *Unity*.
98+
* Do NOT capitalize "editor" when writing *Unity editor*.
99+
100+
### Emphasis and highlighting
101+
102+
There are two ways to emphasize or highlight words, making them bold or making them italic. The effect of bold text is that **bold text sticks out** and therefore can easily be noticed while skimming a piece of text or even just scrolling over a page. Bold is great to highlight phrases that people should remember. However, **use bold text rarely**, because it is generally distracting.
103+
104+
Often one wants to either 'group' something that belongs logically together or highlight a specific term, because it has a special meaning. Such things do not need to stand out of the overall text. Use italic text as a *lightweight method* to highlight something.
105+
106+
Similarly, when a filename, a path or a menu-entry is mentioned in text, prefer to make it italic to logically group it, without being distracting.
107+
108+
In general, try to **avoid unnecessary text highlighting**. Special terms can be highlighted once to make the reader aware, do not repeat such highlighting throughout the text, when it serves no purpose anymore and only distracts.
109+
110+
### Mentioning menu entries
111+
112+
When mentioning a menu entry that a user should click, the current convention is:
113+
114+
*Project > Files > Create > Leaf*
115+
116+
### Links
117+
118+
Insert as many useful links to other pages as possible, but each link only once. Assume a reader clicks on every link in your page, and think about how annoying it would be, if the same page opens 20 times.
119+
120+
Prefer links embedded in a sentence:
121+
122+
* BAD: Guidelines are useful. See [this chapter](DocumentationGuide.md) for details.
123+
* GOOD: [Guidelines](DocumentationGuide.md) are useful.
124+
125+
Avoid external links, they can become outdated or contain copyrighted content.
126+
127+
When you add a link, consider whether it should also be listed in the [See also](#see-also) section. Similarly, check whether a link to your new page should be added to the linked-to page.
128+
129+
### Images / screenshots
130+
131+
**Use screenshots sparingly.** Maintaining images in documentation is a lot of work, small UI changes can make a lot of screenshots outdated. The following rules will reduce maintenance effort:
132+
133+
1. Do not use screenshots for things that can be described in text. Especially, **never screenshot a property grid** for the sole purpose of showing property names and values.
134+
2. Do not include things in a screenshot that are irrelevant to what is shown. For instance, when a rendering effect is shown, make a screenshot of the viewport, but exclude any UI around it. When you have to show some UI, try to move windows around such that only that important part is in the image.
135+
3. When you do screenshot UI, only show the important parts. For example, when talking about buttons in a toolbar, you can make a small image that shows the important toolbar buttons, but exclude everything around it.
136+
4. Only use images that are easy to reproduce. That means do not paint markers or highlights into screenshots. First, there are no consistent rules how these should look, anyway. Second, reproducing such a screenshot is additional effort. Instead, describe the important parts in text. There are exceptions to this rule, but they are rare.
137+
5. Obviously, it is much more effort to recreate an animated GIF. If you make one, expect to be responsible to recreate it for the rest of your life, or expect people to throw it out, if they don't want to spend that time.
138+
6. Keep the number of images in an article low. Often a good method is to make one overall screenshot of some tool, that shows everything, and then describe the rest in text. This makes it easy to replace the screenshot when necessary.
139+
140+
Some other aspects:
141+
142+
* Default image width is 500 pixels, as this displays well on most monitors. Try not to deviate too much from it. 800 pixels width should be the maximum.
143+
* Use PNGs for screenshots of UI.
144+
* Use PNGs or JPGs for 3D viewport screenshots. Prefer quality over compression ratio.
145+
146+
### List of component properties
147+
148+
When documenting a list of properties, use bold text to highlight the property name, then line breaks and regular text to describe them. Do not use sub-chapters or bullet point lists.
149+
150+
Also, don't forget to finish all sentences with a period.
151+
152+
## When you are finished with a page
153+
154+
First off, it is ok for a 'finished' page to contain [TODO comments](#todo-comments). However, once you stop working on a page, please do the following:
155+
156+
1. Make sure you followed the guidelines in this document.
157+
1. Browse the document structure and see if your new document could be mentioned under the [See also](#see-also) section of other pages.
158+
1. If available, have someone with knowledge of the topic proof-read the page for technical correctness.
159+
1. Have someone proof-read your page for style and formatting. This can be someone unfamiliar with the topic, which is also a good idea to get feedback about how understandable the documentation is.
160+
161+
162+
## Source documentation
163+
API documentation will be generated automatically from the MRTK source files. To facilitate this, source files are required to contain the following:
164+
165+
- [Class, struct, enum summary blocks](#class-struct-enum-summary-blocks)
166+
- [Property, method, event summary blocks](#property-method-event-summary-blocks)
167+
- [Feature introduction version and dependencies](#feature-introduction-version-and-dependencies)
168+
- [Serialized fields](#serialized-fields)
169+
- [Enumeration values](#enumeration-values)
170+
171+
In addition to the above, the code should be well commented to allow for maintenance, bug fixes and ease of customization.
172+
173+
### Class, struct, enum summary blocks
174+
If a class, struct or enum is being added to the MRTK, it's purpose must be described. This is to take the form of a summary block above the class.
175+
176+
```
177+
/// <summary>
178+
/// AudioOccluder implements IAudioInfluencer to provide an occlusion effect.
179+
/// </summary>
180+
```
181+
182+
If there are any class level dependencies, they should be documented in a remarks block, immediately below the summary.
183+
184+
```
185+
/// <remarks>
186+
/// Ensure that all sound emitting objects have an attached AudioInfluencerController.
187+
/// Failing to do so will result in the desired effect not being applied to the sound.
188+
/// </remarks>
189+
```
190+
191+
Pull Requests submitted without summaries for classes, strutures or enums will not be approved.
192+
193+
### Property, method, event summary blocks
194+
Properties, methods and events (PMEs) as well as fields are to be documented with summary blocks, regardless of code visibility (public, private, protected and internal). The documentation generation tool is responsible for filtering out and publishing only the public and protected features.
195+
196+
NOTE: A summary block is **not** required for Unity methods (ex: Awake, Start, Update).
197+
198+
PME documentation is **required** for a pull request to be approved.
199+
200+
As part of a PME summary block, the meaning and purpose of parameters and returned data is required.
201+
202+
```
203+
/// <summary>
204+
/// Sets the cached native cutoff frequency of the attached low pass filter.
205+
/// </summary>
206+
/// <param name="frequency">The new low pass filter cutoff frequency.</param>
207+
/// <returns>The new cutoff frequency value.</returns>
208+
209+
```
210+
211+
### Feature introduction version and dependencies
212+
As part of the API summary documentation, information regarding the MRTK version in which the feature was introduced and any dependencies should be documented in a remarks block.
213+
214+
Dependencies should include extension and/or platform dependencies.
215+
216+
```
217+
/// <remarks>
218+
/// Introduced in MRTK version: 2018.06.0
219+
/// Minimum Unity version: 2018.0.0f1
220+
/// Minimum Operating System: Windows 10.0.11111.0
221+
/// Requires installation of: ImaginarySDK v2.1
222+
/// </remarks>
223+
```
224+
225+
### Serialized fields
226+
It is a good practice to use Unity's tooltip attribute to provide runtime documentation for a script's fields in the inspector.
227+
228+
So that configuration options are included in the API documentation, scripts are required to include *at least* the tooltip contents in a summary block.
229+
230+
```
231+
/// <summary>
232+
/// The quality level of the simulated audio source (ex: AM radio).
233+
/// </summary>
234+
[Tooltip("The quality level of the simulated audio source.")]
235+
```
236+
237+
### Enumeration values
238+
When defining and enumeration, code must also document the meaning of the enum values using a summary block. Remarks blocks can optionally be used to provide additional details to enhance understanding.
239+
240+
```
241+
/// <summary>
242+
/// Full range of human hearing.
243+
/// </summary>
244+
/// <remarks>
245+
/// The frequency range used is a bit wider than that of human
246+
/// hearing. It closely resembles the range used for audio CDs.
247+
/// </remarks>
248+
```
249+
250+
251+
## How-to documentation
252+
253+
Many users of the Mixed Reality Toolkit may not need to use the API documentation. These users will take advantage of our pre-made, reusable prefabs and scripts to create their experiences.
254+
255+
Each feature area will contain one or more markdown (.md) files that describe at a fairly high level, what is provided. Depending on the size and/or complexity of a given feature area, there may be a need for additional files, up to one per feature provided.
256+
257+
When a feature is added (or the usage is changed), overview documentation must be provided.
258+
259+
As part of this documentation, how-to sections, including illustrations, should be provided to assist customers new to a feature or concept in getting started.
260+
261+
262+
## Design documentation
263+
264+
Mixed Reality provides an opportunity to create entirely new worlds. Part of this is likely to involve the creation of custom assets for use with the MRTK. To make this as friction free as possible for customers, components should provide design documentation describing any formatting or other requirements for art assets.
265+
266+
Some examples where design documentation can be helpful:
267+
- Cursor models
268+
- Spatial mapping visualizations
269+
- Sound effect files
270+
271+
This type of documentation is **strongly** recommended, and **may** be requested as part of a pull request review.
272+
273+
This may or may not be different from the design recommendation on the [MS Developer site](https://docs.microsoft.com/en-us/windows/mixed-reality/design)
274+
275+
276+
## Performance notes
277+
278+
Some important features come at a performance cost. Often this code will very depending how they are configured.
279+
280+
For example:
281+
```
282+
When using the spatial mapping component, the performance impact will increase with the level of detail requested. It is recommended to use the least detail possible for your experience.
283+
```
284+
285+
Performance notes are recommended for CPU and/or GPU heavy components and **may** be requested as part of a pull request review. Any applicable performance notes are to be included in API **and** overiew documentation.
286+
287+
288+
## Breaking changes
289+
290+
Breaking changes documentation is to consist of a top level [file](../BreakingChanges.md) which links to each feature area's individual BreakingChanges.md.
291+
292+
The feature area BreakingChanges.md files are to contain the list of all known breaking changes for a given release **as well as** the history of breaking changes from past releases.
293+
294+
For example:
295+
```
296+
Spatial sound breaking changes
297+
298+
2018.07.2
299+
* Spatialization of the imaginary effect is now required.
300+
* Management of randomized AudioClip files requires an entropy value in the manager node.
301+
302+
2018.07.1
303+
No known breaking changes
304+
305+
2018.07.0
306+
...
307+
```
308+
309+
The information contained within the feature level BreakingChanges.md files will be aggregated to the release notes for each new MRTK release.
310+
311+
Any breaking changes that are part of a change **must** be documented as part of a Pull Request.
312+
313+
314+
## See also
315+
316+
* [Documentation portal generation guide](DevDocGuide.md)

Documentation/toc.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@
114114
href: ../Feature_Contribution_Process.md
115115
- name: Coding Guidelines
116116
href: ../CodingGuidelines.md
117-
- name: Documentation Guide
118-
href: ../DocumentationGuide.md
119-
- name: Developer Docs Generation
117+
- name: Documentation guide
118+
href: DocumentationGuide.md
119+
- name: Developer portal generation with DocFX
120120
href: DevDocGuide.md
121121
- name: Planning
122122
items:

0 commit comments

Comments
 (0)