SS14 Documentation Writing
Use this skill as a strict working standard for documentation in SS14 ✍️
Goal: leave only useful documentation that speeds up reviews and reduces the risk of incorrect system expansion.
Reading order
- Read
references/fresh-pattern-catalog.mdfirst. - Then read
references/rejected-snippets.md. - At the end, check the context in
references/docs-context.md.
Source of truth
- The source of truth for documentation rules is the current code.
- Documentation from
docsis required reading, but is used as a secondary layer (terms, intent, restrictions) because it may lag. - For any target subsystem, always look not only at the system itself, but also at its usage in
server/shared/client, especially unusual calls and non-standard flags. - Cut off examples older than cutoff
2024-02-20. - Do not use fragments with
TODO/HACK/FIXMEas a reference if they affect the documentation itself or show controversial behavior.
Basic rules
Language
- Write comments and all XML documentation text in fork-owned code (
_Sunrise,_Scp,_Fish,_Lust,Sunrise editblocks) in Russian, including text in<summary>,<remarks>,<param>, and<returns>. - Upstream comments are never translated or rewritten, even next to a fork edit; identifiers, XML tags and API names stay English.
- Logs stay in English.
C# and SWSL
- Use
/// <summary>as the main documentation format in your code. - Document public methods, public API points and DataField contracts via
summary. - For partial classes, add a short description of the role of the specific part immediately below the class declaration and before the dependency block.
- For complex mathematics, non-standard state transitions, prediction nuances and workaround logic, add a short comment above the logic block, even if the method already has
summary. - Don't comment out every line and every obvious
if"for the sake of commenting." - Check the validity of XML documents: correct tags and case (
</summary>, not</summarY>).
YAML prototypes
- Separate groups of prototypes with comments.
- If the comment describes the behavior of the prototype, limit it to one sentence.
- Don’t turn prototypes into “sheets” of multi-line explanations.
- Do not use edit markers as “documentation” (
Start/Endblocks without meaning for behavior).
FTL
- Use comments in FTL only for rare divisions into groups.
- Always put a space between
##and the group name:## Group Name. - Do not use broken headers like
##bombs. - Don't spam headers before every few keys.
Workflow for documenting the subsystem
- Find the main contract of the subsystem: what external calls are required to know.
- View all main callsite in
server/shared/client. - Mark non-standard calls (additional flags, special-case paths, bypassing standard checks).
- Record these places in
summaryand short point-by-point comments “why is this so”. - Remove noise: any comments that simply paraphrase a line of code.
Decision Tree
- Is this a public contract/method/type?
Write summary.
- Is this a complex, non-obvious block (mathematics, prediction, workaround)?
Write a short comment above the block + leave summary at the method level.
- Is this obvious local code?
Don't comment.
- Is this a partial part of a larger system?
Add the title of the part role and the meaning of the dependency block.
- Is this a YAML/FTL grouping?
Give a short separator, without a long description.
Patterns ✅
ClickableSystemandCheckClick(...)usesummaryfor the contract and point comments in places with complex coordinate transformations.MimePowersSystem.OnInvisibleWall(...)is documented bysummary, and comments are left only on critical checks.- In
AccessOverriderSystempublic methods combinesummaryandremarkswhen you need to capture a behavior invariant. BaseContainerandSharedContainerSystem.Remove(...)show a stable API documentation style:summary+remarks+ described parameters.- In
SharedScp096Systemthe logic is decomposed into partial parts with separate blocks of responsibilities and dependencies. Scp096PhotoSystemandArtifactScp096MadnessSystemshow that the documentation should take into account non-standard call flags (TryAddTarget(..., true, true)), and not just the default path.- In YAML directories, level separators
# Rank 2/# Rank 3make large lists readable without overload. - In FTL, the correct group separator is
## Strings for the battery ...and does not break parsing.
Anti-patterns ❌
- Invalid XML tags in docks (
</summarY>and other typos). - A newly authored fork-owned documentation block contains multiple languages, or an upstream comment is translated or rewritten.
- Obvious comments that simply duplicate a line of code.
- Using
TODO/HACK/FIXMEas "documentation of behavior" instead of a correction or normal explanation. - Multi-line explanations in YAML where one phrase is enough.
- Edit markers (
Sunrise edit start/end,Fire added start/end) instead of behavioral description. - FTL headers without space after
##(##bombs). - Frequent or decorative FTL separators (
##########) that do not help navigation.
Code examples
Example 1: `summary` + dot comments on complex logic
/// <summary>
/// Handles click detection for sprites.
/// </summary>
public sealed class ClickableSystem : EntitySystem
{
/// <summary>
/// Used to check whether a click worked.
/// </summary>
public bool CheckClick(...)
{
// First we get localPos, the clicked location in the sprite-coordinate frame.
...
// Next check each individual sprite layer using automatically computed click maps.
...
}
}
Comment: summary holds the API contract, and inline comments remain only for non-obvious steps.
Example 2: short comments only on really important checks
/// <summary>
/// Creates an invisible wall in a free space after some checks.
/// </summary>
private void OnInvisibleWall(Entity<MimePowersComponent> ent, ref InvisibleWallActionEvent args)
{
// Get the tile in front of the mime
...
// Check if the tile is blocked by a wall or mob, and don't create the wall if so
...
// Make sure we set the invisible wall to despawn properly
...
}
Comment: Comments do not clutter the method, but only clarify the checks and consequences.
Example 3: `summary` + `remarks` for invariants
/// <summary>
/// Returns true if there is an ID in privileged slot and said ID satisfies access requirements.
/// </summary>
/// <remarks>
/// Other code relies on the fact this returns false if privileged Id is null.
/// </remarks>
private bool PrivilegedIdIsAuthorized(...)
{
...
}
Comment: remarks fixes an invariant that is otherwise easy to break with a refactor.
Example 4: partial decomposition + analysis of non-standard calls
public abstract partial class SharedScp096System
{
/*
* Target-handling part of the system.
*/
[Dependency] private SharedPopupSystem _popup = default!;
...
}
if (!_scp096.TryAddTarget((uid, scp096), args.Examiner, true, true))
continue;
Comment: For such systems, document not only “what the part does”, but also why the callsite includes non-standard flags.
Example 5: YAML grouping without overloading
# Rank 2
- type: cargoProduct
id: CargoDoubleEmergencyTank
# Rank 3
- type: cargoProduct
id: CargoFulton
Comment: A short delimiter speeds up reading and does not turn into an additional "document inside the prototype".
Example 6: FTL delimiters
## Strings for the battery (SMES/substation) menu
battery-menu-out = OUT
##bombs
uplink-pizza-bomb-name = Nefarious Pizza bomb
Comment: the first header is correct, the second is broken due to the lack of a space after ##.
Checklist before PR
- New comments and all XML documentation text in fork-owned code are in Russian. Upstream comments are untouched. Logs are in English.
- Added
summaryfor public and intersystem contracts. - In partial systems there is a brief description of the role of the part.
- Complex blocks received a short explanation "why".
- In YAML, comments are short and only to the point.
- In FTL, group comments are rare and only in the format
## Group Name. - There are no invalid XML tags or broken FTL headers.
Extension rule
- Add new rules only after confirmation with fresh code and viewing callsite.
- First fix controversial or legacy examples as anti-patterns.
- If the topic grows (for example, only guidebook XML or only UI localization), move it to a separate specialized skill.
Document so that the next developer understands the contract without archeology of the code :)