mkdocstrings / typescript

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

TypeError: ConstructorSignature.__init__() got an unexpected keyword argument 'inherited_from' #11

Closed adaxi closed 2 months 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 A = number

export abstract class D {
    abstract f (): number
    e (): number {
        return 1
    }
}

export class Z extends D {
  e () {
    return 2
  }

  f (){
    return 1
  }
}
/**
 * @class 
 */
export class C extends Z {
  private a: A

  /**
   * Silly example
   * 
   * @param {string} a this is a number
   */
  constructor (a: A) {
    super()
    this.a = a
  }

  e() {
    return this.a
  }

  f() {
    return 2;
  }
}
INFO    -  Cleaning site directory
INFO    -  Building documentation to directory: /home/gbo/Workspaces/reproducer/docs/site
INFO    -  griffe_typedoc: JSON written to /tmp/tmpom_mmaaa
ERROR   -  Error reading page 'index.md': ConstructorSignature.__init__() got an unexpected keyword argument 'inherited_from'
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 542, in _object_hook
    return _loader_map[kind](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 159, in _load_constructor_signature
    return ConstructorSignature(**obj_dict)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: ConstructorSignature.__init__() got an unexpected keyword argument 'inherited_from'
pawamoy commented 2 months ago

Fixed in griffe-typedoc v0.0.0.0.2.3 :slightly_smiling_face: