Skip to content

Libdoc: TypedDict types shall be documented in spec files as Enums are. #3784

Closed

Description

@Snooz82

Enums are documented in JSON and XML output of Libdoc.
TypedDict argument types shall also be documented, so that a user of these files do know whick keys are expected and which types these keys must have.

Robot Framework does auto conversion to dict, if the given type hint is a typing.TypedDict.
BUT what structure that dict should have is not visible to the user.

When storing Typed Dict also in JSON, HTML could document this to the users and library creaters does not have to document it twice.

Activity

  1. added this to the v4.0 milestone on Nov 29, 2020
  2. linked a pull request that will close this issueDataTypes in Libdoc Specs #3743on Nov 29, 2020
  3. Snooz82 commented on Nov 29, 2020

    @Snooz82
    MemberAuthor

    Typed Dicts are documented like this in JSON

    "typedDicts": [
          {
            "name": "GeoLocation",
            "type": "TypedDict",
            "doc": "<p>Defines the geolocation.</p>\n<ul>\n<li><code>latitude</code> Latitude between -90 and 90.</li>\n<li><code>longitude</code> Longitude between -180 and 180.</li>\n<li><code>accuracy</code> <b>Optional</b> Non-negative accuracy value. Defaults to 0. Example usage: <code>{'latitude': 59.95, 'longitude': 30.31667}</code></li>\n</ul>",
            "items": [
              {
                "key": "longitude",
                "type": "float",
                "required": true
              },
              {
                "key": "latitude",
                "type": "float",
                "required": true
              },
              {
                "key": "accuracy",
                "type": "float",
                "required": false
              }
            ]
          }
        ]
    

    and like this in XML

    <typed_dict name="GeoLocation">
        <doc>Defines the geolocation.
    
        - ``latitude`` Latitude between -90 and 90.
        - ``longitude`` Longitude between -180 and 180.
        - ``accuracy`` *Optional* Non-negative accuracy value. Defaults to 0.
        Example usage: ``{'latitude': 59.95, 'longitude': 30.31667}``</doc>
        <items>
            <item key="longitude" type="float" required="true"/>
            <item key="latitude" type="float" required="true"/>
            <item key="accuracy" type="float" required="false"/>
        </items>
    </typed_dict>
    
  4. removed this from the v4.0 milestone on Nov 30, 2020
  5. pekkaklarck commented on Nov 30, 2020

    @pekkaklarck
    Member

    Let's merge this with the issue about storing enum info in specs (#3607).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions