Skip to content

Proposal for API Docs #772

@richlander

Description

@richlander

Proposal for API Docs

API documentation is important! We need to define the following:

  • The user experience of viewing documentation.
  • How the content will be structured.

See existing docs and content: https://docs.microsoft.com/en-us/dotnet/core/api/system.

Requirements

  • The docs will represent multiple .NET products.
  • There must be good UX for navigating and filtering across the products.
  • The content will be open source and be moved to a single location (core-docs).

Assumptions

The APIs are the same across all products, including implemented interfaces and class inheritance. In some cases, this won't be true. If it's an exception, we'll decide that one implementation is the default and any others are correctly described in remarks.

Scope

The docs will document .NET APIs in:

Frameworks:

  • .NET Core (including for UWP)
  • .NET Framework
  • .NET Standard
  • Mono

Libraries:

  • ASP.NET / Core
  • EF
  • NuGet

UX

The user experience should bias towards seeing all APIs while providing soft-filters and cues to define which APIs are implemented in the various products. This is primarily an issue for the frameworks listed above, as opposed to the libraries.

Representation

  • One canonical representation per API (e.g. one page for System.String type; not one for Mono and one for .NET Framework).
  • Remarks will discuss product specific behavior, as appropriate.

URLS

URLs are easy to predict and hack.

Hacking means that the following URLs should go somewhere useful:

API Version Filtering

The default experience is viewing all .NET APIs, unfiltered by product or release. You can filter your view in terms of a product and version, such as .NET Framework 4.5, .NET Standard 1.5 or Mono 4.4.

Good example of version navigation: https://developer.android.com/reference/packages.html. The Android experience always shows all APIs and greys some of them out. That's a great experience. The "Platform" toggle on this page is not a good experience: https://docs.microsoft.com/en-us/active-directory/adal/microsoft.identitymodel.clients.activedirectory.

Describing Product Membership

The unfiltered view states all .NET products that support a given type/member, independent of filter. For example, when viewing pages in terms of Mono, you see "Introduced in Mono 1.1, .NET Framework 2.0, ...".

Two options for the filtered view:

  • Same as the unfiltered view.
  • State the "Introduced in" only for the filtered product (e.g. "Introduced in Mono 1.1" when viewing in terms of Mono 4.4 or Mono latest).

View Source

The "View source" should take you to the product source for a given type or member. It should take you to the specific product in the filtered view and a default product in the unfiltered view.

Product version is not important for this experience, only product.

Examples, for the Filtered case:

  • .NET Core: use CoreFX repo.
  • Mono: use Mono repo
  • .NET Framework: use referencesource repo or http://sourceof.net

For unfiltered, use a precedence algorithm, based on API availability information from reference assemblies:

  • corefx
  • referencesource
  • mono

Improve this Doc

Assumption: All docs are in the core-docs repo.

There are two ways to improve a document, either via updating the .cs file or the sidecar file. The "Improve this doc" button can only go to one place. Both files should contain a fully-qualified GitHub link to the other file (in a comment), so that it's easy to go from one file to the other.

Proposal: The button takes you to the .cs file. It's an open question of whether it should be in "edit" or "view" mode on GitHub.

Format

  • /// comments in .cs files, one file per type
  • The .cs files are skeletal versions of types, much like: https://github.com/dotnet/corefx/blob/master/src/System.Collections/ref/System.Collections.cs
  • Remarks are in a sidecar file, one per type.
  • These files include APIs for the union of all .NET products, enabling all .NET APIs to be documented.
  • No decoration of types or members in these files for .NET product membership (e.g. part of .NET Framework 4.5.1). We can query reference assemblies for that.

File structure

Versioning

The repository does not version, in terms of branching. There will not be branches for given .NET product releases. It's certainly fine to branch as part of a release, but the branch will be temporary. Given that the repository is for multiple products, the branches would not be meaningful / intuitive.

Relationship to Product Source

/// comments will be copied to product source on some cadence. One option is to snapshot /// comments from core-docs into corefx (for example) once per release, at the start of the release. This means that /// comments in product source will always be one release behind, but also won't disrupt product source at an unfortunate time.

Adding new APIs

There needs to be a tool that can take a set of reference assemblies and then add new APIs into the .cs files that are not present as stubs (empty /// comments).

Extra effort: A tool that prints out types and members that are missing /// comments.

Projects that already have /// comments

Projects (basically all the libraries) like ASP.NET Core already have /// comments within the product source. They don't have to change what they are doing.

In those cases, "View Source" and "Improve this Doc" will go to the same place, to the product source.

We need to decide for these projects where the sidecar files will go. Ideally, they'll go in the product repo, beside the files, potentially in a subdirectory. There isn't much value in splitting this content and requiring contributors for that content to clone two repos.

IntelliSense

IntelliSense will need to be generated from these same files. We'll need a similar tool that generates intellisense files from the .cs files plus a set of reference assemblies that defines a given platform.

Metadata

Metadata

Assignees

No one assigned

    Labels

    discussionIndicates issues that are being discussed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions