Skip to content

Commit 1971230

Browse files
authored
Manual fixes, pass 1 (#761)
1 parent 92fb39b commit 1971230

File tree

19 files changed

+434
-355
lines changed

19 files changed

+434
-355
lines changed

Assets/Tests/InputSystem/APIVerificationTests.cs

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Mono.Cecil;
88
using UnityEditor.PackageManager.DocumentationTools.UI;
99
using UnityEngine.InputSystem;
10+
using HtmlAgilityPack;
1011

1112
class APIVerificationTests
1213
{
@@ -318,5 +319,77 @@ public void API_DoesNotHaveUndocumentedPublicMethods()
318319
var undocumentedMethods = GetInputSystemPublicMethods().Where(m => !IgnoreMethodForDocs(m) && string.IsNullOrEmpty(MethodSummary(m, docsFolder)));
319320
Assert.That(undocumentedMethods, Is.Empty, $"Got {undocumentedMethods.Count()} undocumented methods.");
320321
}
322+
323+
HtmlDocument LoadHtmlDocument(string htmlFile, Dictionary<string, HtmlDocument> htmlFileCache)
324+
{
325+
if (!htmlFileCache.ContainsKey(htmlFile))
326+
{
327+
htmlFileCache[htmlFile] = new HtmlDocument();
328+
htmlFileCache[htmlFile].Load(htmlFile);
329+
}
330+
331+
return htmlFileCache[htmlFile];
332+
}
333+
334+
void CheckHTMLFileLinkConsistency(string htmlFile, List<string> unresolvedLinks, Dictionary<string, HtmlDocument> htmlFileCache)
335+
{
336+
var dir = Path.GetDirectoryName(htmlFile);
337+
var doc = LoadHtmlDocument(htmlFile, htmlFileCache);
338+
var hrefList = doc.DocumentNode.SelectNodes("//a")
339+
.Select(p => p.GetAttributeValue("href", null))
340+
.ToList();
341+
foreach (var _link in hrefList)
342+
{
343+
var link = _link;
344+
if (string.IsNullOrEmpty(link))
345+
continue;
346+
347+
// ignore external links for now
348+
if (link.StartsWith("http://"))
349+
continue;
350+
351+
if (link.StartsWith("https://"))
352+
continue;
353+
354+
if (link == "#top")
355+
continue;
356+
357+
if (link.StartsWith("#"))
358+
link = Path.GetFileName(htmlFile) + link;
359+
360+
var split = link.Split('#');
361+
var linkedFile = split[0];
362+
var tag = split.Length > 1 ? split[1] : null;
363+
364+
if (!File.Exists(Path.Combine(dir, linkedFile)))
365+
{
366+
unresolvedLinks.Add($"{link} in {htmlFile} (File Not Found)");
367+
continue;
368+
}
369+
370+
if (!string.IsNullOrEmpty(tag))
371+
{
372+
var linkedDoc = LoadHtmlDocument(Path.Combine(dir, linkedFile), htmlFileCache);
373+
var idNode = linkedDoc.DocumentNode.SelectSingleNode($"//*[@id = '{tag}']");
374+
if (idNode == null)
375+
unresolvedLinks.Add($"{link} in {htmlFile} (Tag Not Found)");
376+
}
377+
}
378+
}
379+
380+
[Test]
381+
[Category("API")]
382+
#if UNITY_EDITOR_OSX
383+
[Explicit] // Fails due to file system permissions on yamato, but works locally.
384+
#endif
385+
public void API_DocumentationManualDoesNotHaveMissingInternalLinks()
386+
{
387+
var docsFolder = GenerateDocsDirectory();
388+
var unresolvedLinks = new List<string>();
389+
var htmlFileCache = new Dictionary<string, HtmlDocument>();
390+
foreach (var htmlFile in Directory.EnumerateFiles(Path.Combine(docsFolder, "manual")))
391+
CheckHTMLFileLinkConsistency(htmlFile, unresolvedLinks, htmlFileCache);
392+
Assert.That(unresolvedLinks, Is.Empty);
393+
}
321394
}
322395
#endif
159 KB
Binary file not shown.

Assets/Tests/InputSystem/Unity.InputSystem.Tests.asmdef

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,22 @@
44
"Unity.InputSystem",
55
"Unity.InputSystem.TestFramework",
66
"Unity.ugui",
7-
"Unity.PackageManagerDocTools.Editor"
8-
],
9-
"optionalUnityReferences": [
10-
"TestAssemblies"
7+
"Unity.PackageManagerDocTools.Editor",
8+
"UnityEngine.TestRunner",
9+
"UnityEditor.TestRunner"
1110
],
1211
"includePlatforms": [],
1312
"excludePlatforms": [],
1413
"allowUnsafeCode": true,
1514
"overrideReferences": true,
1615
"precompiledReferences": [
17-
"Mono.Cecil.dll"
16+
"Mono.Cecil.dll",
17+
"nunit.framework.dll",
18+
"HtmlAgilityPack.dll"
19+
],
20+
"autoReferenced": false,
21+
"defineConstraints": [
22+
"UNITY_INCLUDE_TESTS"
1823
],
19-
"autoReferenced": true,
20-
"defineConstraints": [],
2124
"versionDefines": []
2225
}

Packages/com.unity.inputsystem/Documentation~/ActionBindings.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ This problem is solved by "composite bindings", i.e. bindings that are made up o
3333

3434
>NOTE: Actions set on bindings that are part of composites are ignored. The composite as a whole can trigger an action. Individual parts of the composite cannot.
3535
36-
To see how to create composites in the editor UI, see [here](ActionEditor.md#editing-composite-bindings).
36+
To see how to create composites in the editor UI, see [here](ActionAssets.md#editing-composite-bindings).
3737

3838
In code, composites can be created using the `AddCompositeBinding` syntax.
3939

@@ -216,6 +216,10 @@ This behavior can be overridden by restricting `InputActionAssets` or individual
216216

217217
>NOTE: `InputUser` and `PlayerInput` make use of this facility automatically. I.e. they will set `InputActionMap.devices` automatically based on the devices that are paired to the user/player.
218218
219+
## Disambiguation
220+
221+
TODO
222+
219223
## Runtime Rebinding
220224

221225
### Showing Current Bindings

Packages/com.unity.inputsystem/Documentation~/Actions.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Actions can be created in a variety of ways:
7878

7979
### Using the Action Editor
8080

81-
How to create and edit input action assets using the dedicated editor is described on a [separate page](ActionEditor.md).
81+
How to create and edit input action assets using the dedicated editor is described on a [separate page](ActionAssets.md).
8282

8383
![Action Editor Window](Images/MyGameActions.png)
8484

@@ -100,7 +100,7 @@ This is presented in the editor like so:
100100

101101
![MyBehavior Inspector](Images/MyBehaviorInspector.png)
102102

103-
The editors work similar to the [action asset editor](ActionEditor.md).
103+
The editors work similar to the [action asset editor](ActionAssets.md).
104104

105105
* To add or remote actions or bindings, click the plus or minus icon in the header.
106106
* To edit binding entries, double-click them.<br>
@@ -109,7 +109,7 @@ The editors work similar to the [action asset editor](ActionEditor.md).
109109
![InputAction Inspector](Images/InputActionInspector.png)
110110
* Entries can also be right-clicked to bring up a context menu and can be dragged around (hold alt to duplicate).
111111

112-
Actions and action maps that are embedded in MonoBehaviour components have to be manually [enabled and disabled](#enabling-and-disabling-actions).
112+
Actions and action maps that are embedded in MonoBehaviour components have to be manually [enabled and disabled](#using-actions).
113113

114114
```CSharp
115115
public class MyBehavior : MonoBehaviour
@@ -207,13 +207,13 @@ By itself, an action does not represent an actual response to input. Instead, an
207207
There are several ways in which this can be done.
208208

209209
1. Each action has a [`started`, `performed`, and `cancelled` callback](#started-performed-and-cancelled-callbacks).
210-
2. Each action map has an [`actionTriggered` callback](#inputactionmap-actiontriggered-callback).
211-
3. There is a global [`InputSystem.onActionChange` callback](#inputsystem-onactionchange-callback).
210+
2. Each action map has an [`actionTriggered` callback](#inputactionmapactiontriggered-callback).
211+
3. There is a global [`InputSystem.onActionChange` callback](#inputsystemonactionchange-callback).
212212
4. [`InputActionTrace`](#inputactiontrace) can record changes happening on actions.
213213

214214
>NOTE: A polling API for actions is on the TODO list.
215215
216-
There are also higher-level, more streamlined ways of picking up input from actions. One is to use [`PlayerInput`](Components.md#notification-behaviors) and another one is to [generate script code](ActionEditor.md#generating-script-code) that wraps around the input actions.
216+
There are also higher-level, more streamlined ways of picking up input from actions. One is to use [`PlayerInput`](Components.md#notification-behaviors) and another one is to [generate script code](ActionAssets.md#auto-generating-script-code-for-actions) that wraps around the input actions.
217217

218218
#### `started`, `performed`, and `cancelled` Callbacks
219219

@@ -241,7 +241,7 @@ The `Started`, `Performed`, and `Cancelled` phases each have a callback associat
241241

242242
Each callback receives an `InputAction.CallbackContext` structure holding context information that can be used to query the current state of the action and to read out values from controls that triggered the action (`InputAction.CallbackContext.ReadValue`). Note that the contents of the structure are __only valid for the duration of the callback__. In particular, it is not safe to store the received context and later access its properties from outside the callback.
243243

244-
When an how the callbacks are triggered depends on the [interactions](Interactions.md) present on the respective bindings. If no interactions are applied to them, the [default interaction](Interactions.md#default-interactions) applies.
244+
When an how the callbacks are triggered depends on the [interactions](Interactions.md) present on the respective bindings. If no interactions are applied to them, the [default interaction](Interactions.md#default-interaction) applies.
245245

246246
#### `InputActionMap.actionTriggered` Callback
247247

@@ -343,7 +343,7 @@ Once recorded, a trace can be safely read from multiple threads as long as it is
343343

344344
By default, actions will trigger only in response to input events. This means that, for example, an action bound to the left stick of a gamepad will only trigger when the left stick is actually moved. This behavior can be undesirable when an input is meant to register for as long as a control is actuated -- regardless of whether it changes value in a particular frame or not.
345345

346-
This is what "continuous" mode is for. It can be enabled in the UI by selecting the action in the [action editor](ActionEditor.md) and ticking the "Continuous" checkbox.
346+
This is what "continuous" mode is for. It can be enabled in the UI by selecting the action in the [action editor](ActionAssets.md) and ticking the "Continuous" checkbox.
347347

348348
////TODO: Update screenshot
349349

0 commit comments

Comments
 (0)