A practical documentation standard in Space Station 14 for C#, SWSL, YAML and FTL: how to write `<summary>`, when to add explanatory comments, how to document partial systems, and how to avoid noisy documentation. Use it when writing, refactoring and reviewing documentation in code, prototypes and localization.
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.
references/fresh-pattern-catalog.md first.references/rejected-snippets.md.references/docs-context.md.docs is required reading, but is used as a secondary layer (terms, intent, restrictions) because it may lag.server/shared/client, especially unusual calls and non-standard flags.2024-02-20.TODO/HACK/FIXME as a reference if they affect the documentation itself or show controversial behavior./// <summary> as the main documentation format in your code.summary.summary.if "for the sake of commenting."</summary>, not </summarY>).Start/End blocks without meaning for behavior).## and the group name: ## Group Name.##bombs.server/shared/client.summary and short point-by-point comments “why is this so”.summary.summary at the method level.ClickableSystem and CheckClick(...) use summary for the contract and point comments in places with complex coordinate transformations.MimePowersSystem.OnInvisibleWall(...) is documented by summary, and comments are left only on critical checks.AccessOverriderSystem public methods combine summary and remarks when you need to capture a behavior invariant.BaseContainer and SharedContainerSystem.Remove(...) show a stable API documentation style: summary + remarks + described parameters.SharedScp096System the logic is decomposed into partial parts with separate blocks of responsibilities and dependencies.Scp096PhotoSystem and ArtifactScp096MadnessSystem show that the documentation should take into account non-standard call flags (TryAddTarget(..., true, true)), and not just the default path.# Rank 2 / # Rank 3 make large lists readable without overload.## Strings for the battery ... and does not break parsing.</summarY> and other typos).TODO/HACK/FIXME as "documentation of behavior" instead of a correction or normal explanation.Sunrise-Start/End, Fire added start/end) instead of behavioral description.## (##bombs).##########) that do not help navigation.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.
/// <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.
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.
public abstract partial class SharedScp096System
{
/*
* Target-handling part of the system.
*/
[Dependency] private readonly 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.
# 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".
## 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 ##.
summary for public and intersystem contracts.## Group Name.Document so that the next developer understands the contract without archeology of the code :)