def get_docserver_setup(public, stable, server, intranet, group):
    """Returns a setup for BOB_DOCUMENTATION_SERVER.

    What is available to build the documentation depends on the setup of
    ``public`` and ``stable``:

    * public and stable: only returns the public stable channel(s)
    * public and not stable: returns both public stable and beta channels
    * not public and stable: returns both public and private stable channels
    * not public and not stable: returns all channels

    Beta channels have priority over stable channels, if returned.  Private
    channels have priority over public channles, if turned.


    Args:

      public: Boolean indicating if we're supposed to include only public
        channels
      stable: Boolean indicating if we're supposed to include only stable
        channels
      server: The base address of the server containing our conda channels
      intranet: Boolean indicating if we should add "private"/"public" prefixes
        on the returned paths
      group: The group of packages (gitlab namespace) the package we're compiling
        is part of.  Values should match URL namespaces currently available on
        our internal webserver.  Currently, only "bob" or "beat" will work.


    Returns: a string to be used by bob.extension to find dependent
    documentation projects.
    """

    if (not public) and (not intranet):
        raise RuntimeError(
            "You cannot request for private channels and set"
            " intranet=False (server=%s) - these are conflicting options"
            % server
        )

    entries = []

    # public documentation: always can access
    prefix = "/software/%s" % group
    if stable:
        entries += [
            server + prefix + "/docs/" + group + "/%(name)s/%(version)s/",
            server + prefix + "/docs/" + group + "/%(name)s/stable/",
        ]
    else:
        entries += [server + prefix + "/docs/" + group + "/%(name)s/master/"]

    if not public:
        # add private channels, (notice they are not accessible outside idiap)
        prefix = "/private"
        if stable:
            entries += [
                server + prefix + "/docs/" + group + "/%(name)s/%(version)s/",
                server + prefix + "/docs/" + group + "/%(name)s/stable/",
            ]
        else:
            entries += [
                server + prefix + "/docs/" + group + "/%(name)s/master/"
            ]

    return "|".join(entries)