typedoc2md / typedoc-plugin-markdown

A plugin for TypeDoc that enables TypeScript API documentation to be generated in Markdown.
https://typedoc-plugin-markdown.org
MIT License
725 stars 177 forks source link

[typedoc-plugin-markdown@next] Partially generating events #534

Closed CoderIllusionist closed 9 months ago

CoderIllusionist commented 10 months ago

Hi,

Given the following interface;

    interface SimpleComponent {
        /**
          * bla description
         */
        "open"?: boolean;
        /**
          * bla description
          * @eventProperty
          * @deprecated - bla bla
         */
        "onBstToggle"?: (event: BstSimpleComponentCustomEvent<MouseEvent>) => void;
    }

Will resolve to

| Property | Type | Description |
| :------ | :------ | :------ |
| `open?` | `boolean` | bla description |

## Events

| Property | Type | Description |
| :------ | :------ | :------ |
| `onToggleExpansionPanel?` | (`event`) => `void` | - |

***

As you can see the description is empty and it doesn't take @deprecated into account. Any idea how to fix that ? The interface itself is generated by StencilJS. P.S. when not adding the @eventProperty it wont register an event

tgreyuk commented 10 months ago

Thanks - issues should be fixed when using typedoc 0.25.6 and typedoc-plugin-markdown 4.0.0-next.39.

CoderIllusionist commented 10 months ago

Thanks, closing.

CoderIllusionist commented 10 months ago

@tgreyuk i didn't noticed it earlier, but i noticed it always generates (event) => void without the actual typing. BstSimpleComponentCustomEvent contains an detail and target

tgreyuk commented 10 months ago

ok - i'll re-open and investigate...

CoderIllusionist commented 10 months ago

FYI - here's the type decleration file generated by stencil for reference;

/* eslint-disable */
/* tslint:disable */
/**
 * This is an autogenerated file created by the Stencil compiler.
 * It contains typing information for all components that exist in this project.
 */
import { HTMLStencilElement, JSXBase } from "@stencil/core/internal";
import { InputValues } from "./components/my-component/my-component";
export { InputValues } from "./components/my-component/my-component";
export namespace Components {
    interface MyComponent {
        /**
          * The first name
         */
        "first": string;
        /**
          * The last name
         */
        "last": string;
        /**
          * The middle name
         */
        "middle": string;
    }
}
export interface MyComponentCustomEvent<T> extends CustomEvent<T> {
    detail: T;
    target: HTMLMyComponentElement;
}
declare global {
    interface HTMLMyComponentElementEventMap {
        "inputEvent": InputValues;
    }
    interface HTMLMyComponentElement extends Components.MyComponent, HTMLStencilElement {
        addEventListener<K extends keyof HTMLMyComponentElementEventMap>(type: K, listener: (this: HTMLMyComponentElement, ev: MyComponentCustomEvent<HTMLMyComponentElementEventMap[K]>) => any, options?: boolean | AddEventListenerOptions): void;
        addEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
        addEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
        addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
        removeEventListener<K extends keyof HTMLMyComponentElementEventMap>(type: K, listener: (this: HTMLMyComponentElement, ev: MyComponentCustomEvent<HTMLMyComponentElementEventMap[K]>) => any, options?: boolean | EventListenerOptions): void;
        removeEventListener<K extends keyof DocumentEventMap>(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
        removeEventListener<K extends keyof HTMLElementEventMap>(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
        removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
    }
    var HTMLMyComponentElement: {
        prototype: HTMLMyComponentElement;
        new (): HTMLMyComponentElement;
    };
    interface HTMLElementTagNameMap {
        "my-component": HTMLMyComponentElement;
    }
}
declare namespace LocalJSX {
    interface MyComponent {
        /**
          * The first name
         */
        "first"?: string;
        /**
          * The last name
         */
        "last"?: string;
        /**
          * The middle name
         */
        "middle"?: string;
        /**
          * A input event
         */
        "onInputEvent"?: (event: MyComponentCustomEvent<InputValues>) => void;
    }
    interface IntrinsicElements {
        "my-component": MyComponent;
    }
}
export { LocalJSX as JSX };
declare module "@stencil/core" {
    export namespace JSX {
        interface IntrinsicElements {
            "my-component": LocalJSX.MyComponent & JSXBase.HTMLAttributes<HTMLMyComponentElement>;
        }
    }
}

We use LocalJSX namespace and ignore documentation generated for the namespace Components

Source code:

import { Component, Prop, h, Event, EventEmitter } from '@stencil/core';
import { format } from '../../utils/utils';

export type InputValue = undefined | null | boolean | string | number | string[] | Date;

export type InputValues<V = InputValue> = { value: V; oldValue: V };

@Component({
  tag: 'my-component',
  styleUrl: 'my-component.css',
  shadow: true,
})
export class MyComponent {
  /**
   * The first name
   */
  @Prop() first: string;

  /**
   * The middle name
   */
  @Prop() middle: string;

  /**
   * The last name
   */
  @Prop() last: string;

  /**
   * A input event
   */
  @Event() inputEvent:  EventEmitter<InputValues>

  private getText(): string {
    return format(this.first, this.middle, this.last);
  }

  render() {
    return <div>Hello, World! I'm {this.getText()}</div>;
  }
}
CoderIllusionist commented 9 months ago

Hi, any update on this, can I help in any way?

tgreyuk commented 9 months ago

I did update so the param type is displayed in the signature but not sure if this is sufficient. What would be really useful though is an example repo to test against.

CoderIllusionist commented 9 months ago

@tgreyuk I created a repo; https://stackblitz.com/github/CoderIllusionist/typedoc-plugin-demo

It's already fixed indeed, just made the example repo so you could check it. I noticed that the sort typedoc options doesn't work entirely for the properties / events? let me know if i need to create a separate issue for this, you can see the sorting in the demo.

tgreyuk commented 9 months ago

@CoderIllusionist thanks for putting the repo together - that is super useful.

So this is an interesting one. The entry point in this case is a d.ts file generated by stencil which has already been sorted alphbetically. So infact source-order is behaving correctly in this instance:

Screenshot 2024-02-09 at 18 03 59
CoderIllusionist commented 9 months ago

No problem :). Yes indeed, I noticed that after I posted the comment, my bad 😃 . For us the events are fixed, you can close this issue if you want to, I'll try to keep the example repo up and running if you need it.

tgreyuk commented 9 months ago

Ok thanks @CoderIllusionist i will close this one. All this feedback is appreciated and obviously please do continue raising new issues as you find stuff.