Search Unity

Custom Documentation Links

Discussion in 'Package Manager' started by JakHussain, May 24, 2019.

  1. JakHussain

    JakHussain

    Joined:
    Oct 20, 2016
    Posts:
    318
    I've got a package I'm hosting on a verdaccio server and I'm using Docfx to generate a static website on gitlab for my manual and scripting API. Everything works but I want to edit the package.json so that the documentation link in the package manager window sends users to my documentation site and not to Unity's documentation site. Is this possible / in the roadmap? I can't find any details on this.
     
  2. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,050
    Same problem here.
     
  3. Erothez

    Erothez

    Joined:
    May 27, 2015
    Posts:
    20
    `PackageInfo.cs` implies that you can do offline documentation with `Documentation~` etc. but that's only the URI to .md files, with the URL redirect being hardcoded atm.

    The current workaround, as it uses `SearchOption.TopDirectoryOnly`, link to that .md file which then has a link to the rest of the online docs.

    An old comment seems to imply it used to be editable:

    Code (CSharp):
    1. // Module package.json files contain a documentation url embedded in the description.
    2. // We parse that to have the "View Documentation" button direct to it, instead of showing
    3. // the link in the description text.
    But seems this is only for builtin modules?
     
    Last edited: May 25, 2019
  4. phreezie

    phreezie

    Joined:
    Oct 3, 2019
    Posts:
    119
    Any news on this? There is
    changelogUrl
    and
    licensesUrl
    in package.json now, but still looking for a way to link to the documentation site of my package.
     
    yasirkula likes this.
  5. UnityMaru

    UnityMaru

    Community Engagement Manager PSM

    Joined:
    Mar 16, 2016
    Posts:
    1,227
    SugoiDev and yasirkula like this.
  6. phreezie

    phreezie

    Joined:
    Oct 3, 2019
    Posts:
    119
    Thanks, just found it out by trial and error a few days ago. Note there is also:
    • changelogUrl
      pointing to the, uh, changelog
    • licensesUrl
      for the licenses
    EDIT: Uh yeah I've already mentioned that in my post above. Sorry for the noise. ;)
     
    UnityMaru likes this.
  7. Lars-Blaabjerg

    Lars-Blaabjerg

    Joined:
    Apr 5, 2011
    Posts:
    54
    I have found what seems to me like a bug: If the documentationUrl is a link to e.g. a private bitbucket repository, Unity will not open it. It will just show the "This package does not contain offline documentation".
    I assume this is because Unity does the online check by trying to fetch the url before launching the browser, and of course Unity will get a 404 error.
    This is a problem for our in-house packages.
     
  8. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    549
    Hi @Lars-Blaabjerg,

    That's correct, due to an unfortunate design choice, that's how the UI currently implements this flow. It will perform an HTTP HEAD request against the URL and, if it gets a 404 back, it assumes there's no online documentation, in which case it falls back to a local Documentation~ folder. This might not play well with custom packages whose documentation URL points to a private URL, as in your case. You might be able to work around this issue by opening the URL yourself, since you know it exists, and you are probably already signed into your Bitbucket around with your browser. You could do that with a bit of scripting code, e.g. like this :
    Code (CSharp):
    1. var packageInfo = UnityEditor.PackageManager.PackageInfo.FindForAssetPath("Packages/<your-package-name>");
    2. if (!string.IsNullOrEmpty(packageInfo.documentationUrl))
    3.     Application.OpenURL(packageInfo.documentationUrl);
     
    Anthiese likes this.
  9. Gleb_Palchin

    Gleb_Palchin

    Joined:
    Jan 7, 2016
    Posts:
    22
    This is the same problem for our company, we have private packages in a scoped registry, with private documentation, and we want UPM just to open the damn link and not bothering what will it return. Hope it gets fixed soon...
     
  10. maximeb_unity

    maximeb_unity

    Unity Technologies

    Joined:
    Mar 20, 2018
    Posts:
    549
    Hi @Gleb_Palchin,

    This issue was recently fixed, just before the holidays. The fix was released in 2020.3.43f1 and 2023.1.0a23, and it's in flight for 2021.3 LTS and 2022.2 beta. You can track the state of the fix on the Issue Tracker page.