AvinZarlez / unity-tools

A Visual Studio Code Extension to provide some tools for Unity development
https://marketplace.visualstudio.com/items?itemName=Tobiah.unity-tools
MIT License
31 stars 8 forks source link

[FEATURE] Allow for setting Unity documentation version per project #59

Closed mccorkle closed 4 years ago

mccorkle commented 4 years ago

Feature Request

First off, thanks for building this extension. I literally wouldn't be using VsCode in Unity without it.

My feature request is to add the ability for the user to set the version of docs they would like to default to when ctrl-` is pressed.

Problem Description

When I ctrl-` to get to documentation, it defaults to the newest documentation as of the moment I press it. As I am generally working in the LTS versions only, so that means I am often looking at docs that are newer than my editor version.

My Suggestion

Allow the user to specify the target version via something like the following in their settings.json:

{
     "unity-tools.documentationVersion": "2018.4",
}

As this config option would be per project (stored in the {projectFolder}/.vscode/settings.json), this would allow me to manually set the version of the unity editor docs which I would like to see for each project.

Effect of this Feature

When the user highlights a unity keyword and either presses ctrl-` or selects Open documentation for selection, this would change the search string from: https://docs.unity3d.com/ScriptReference/30_search.html?q={Selection}

To something like: https://docs.unity3d.com/2018.4/Documentation/ScriptReference/30_search.html?q=Selection

The 2018.4 in the above example would be the string of unity-tools.documentationVersion in settings.json.

Possible Code

I don't know enough about how extensions are loaded into vscode, so I don't know how to test this and send you a proper PR -- but I believe this is all that you'd need to add to unity-tools/src/search.ts:

var settings: vscode.WorkspaceConfiguration = vscode.workspace.getConfiguration('unity-tools');
var documentationVersion: string[] | undefined = settings.get('documentationVersion');

if (documentationVersion === undefined) {
     let unity_search = "http://docs.unity3d.com/ScriptReference/30_search.html";
} else {
     let unity_search = "http://docs.unity3d.com/" + documentationVersion + "/Documentation/ScriptReference/30_search.html";
}

Possibly Related

This might be resolved in PR #21 (search offline docs), though it may have the same issue as I have multiple editors installed on my pc as well.

Ideally, I would have expected the lookup to check for the most recently focused Unity and just pick the version of the docs that matches that, but I could imagine that being much more of a chore to build.

AvinZarlez commented 4 years ago

Great suggestion! I can implement this when I get the chance.

AvinZarlez commented 4 years ago

Turns out I had some time - Also getting this request was motivating. Feature now available in 1.2