mkdocstrings / typescript

A TypeScript handler for mkdocstrings. Available to sponsors only.
https://mkdocstrings.github.io/typescript
ISC License
2 stars 0 forks source link

ValueError: 'typeOperator' is not a valid TypeKind #6

Closed adaxi closed 1 month ago

adaxi commented 2 months ago

If you take the reproducer in https://github.com/mkdocstrings/typescript/issues/2 and edit the sdk/src/index.ts file to include:

export type ChannelKey = keyof ChannelDevice
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory:
           /home/gbo/Workspaces/reproducer/docs/site
WARNING -  griffe_typedoc: The signature C.constructor has an @param with
           name "a", which was not used
WARNING -  griffe_typedoc: The signature C.constructor has an @param with
           name "b", which was not used
INFO    -  griffe_typedoc: JSON written to /tmp/tmppw7_sccg
WARNING -  griffe_typedoc: Found 0 errors and 2 warnings
ERROR   -  Error reading page 'index.md': 'typeOperator' is not a valid
           TypeKind
Traceback (most recent call last):
  File "/home/gbo/Workspaces/reproducer/docs/.venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/__main__.py", line 288, in build_command
    build.build(cfg, dirty=not clean)
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 310, in build
    _populate_page(file.page, config, files, dirty)
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 167, in _populate_page
    page.render(config, files)
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocs/structure/pages.py", line 285, in render
    self.content = md.convert(self.markdown)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/core.py", line 357, in convert
    root = self.parser.parseDocument(self.lines).getroot()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/blockparser.py", line 117, in parseDocument
    self.parseChunk(self.root, '\n'.join(lines))
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/blockparser.py", line 136, in parseChunk
    self.parseBlocks(parent, text.split('\n\n'))
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/markdown/blockparser.py", line 158, in parseBlocks
    if processor.run(parent, blocks) is not False:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocstrings/extension.py", line 128, in run
    html, handler, data = self._process_block(identifier, block, heading_level)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocstrings/extension.py", line 216, in _process_block
    data: CollectorItem = handler.collect(identifier, options)
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/mkdocstrings_handlers/typescript/handler.py", line 124, in collect
    data = load_typedoc(["typedoc"])
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/loader.py", line 59, in load
    return json.load(tmpfile, cls=TypedocDecoder)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 293, in load
    return loads(fp.read(),
           ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/__init__.py", line 359, in loads
    return cls(**kw).decode(s)
           ^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/json/decoder.py", line 353, in raw_decode
    obj, end = self.scan_once(s, idx)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/decoder.py", line 562, in _object_hook
    return _load_type(obj_dict, self._symbol_map)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/decoder.py", line 69, in wrapper
    obj = func(obj_dict)
          ^^^^^^^^^^^^^^
  File "/home/gbo/Workspaces/reproducer/docs/.venv/lib/python3.11/site-packages/griffe_typedoc/decoder.py", line 427, in _load_type
    type = TypeKind(type)
           ^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 717, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1133, in __new__
    raise ve_exc
ValueError: 'typeOperator' is not a valid TypeKind
pawamoy commented 1 month ago

Could you show what ChannelDevice is? I'm getting Cannot find name 'ChannelDevice'.

pawamoy commented 1 month ago

Just to keep you updated, I've opened this issue: https://github.com/TypeStrong/typedoc/issues/2705. The goal is to properly rewrite the data models so that you don't have to spend so much time reporting issues :sweat_smile:

adaxi commented 1 month ago

Oops, my bad:

export type ChannelDevice = {
    a: number
    b: string
}

export type ChannelKey = keyof ChannelDevice

I don't mind reporting issues, I am really grateful that you have time to process and fix all this so fast!

pawamoy commented 1 month ago

Thanks! griffe-typedoc v0.0.0.0.2.1 published :rocket: