Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime traversal utils for browser usage #2528

Open
NullVoxPopuli opened this issue Mar 20, 2024 · 7 comments
Open

Runtime traversal utils for browser usage #2528

NullVoxPopuli opened this issue Mar 20, 2024 · 7 comments
Labels
enhancement Improved functionality

Comments

@NullVoxPopuli
Copy link

Search terms

  • query
  • util
  • runtime
  • traverse

I found in response to one of my other questions: #2392
These were suggested;

how do I get access to these?

Question

how do I get access to traversal utils? is the browser bundle small? (should be 0 dependencies, yeah?)

@NullVoxPopuli NullVoxPopuli added the question Question about functionality label Mar 20, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 20, 2024

There are not - typedoc doesn't provide a browser bundle. Theoretically the models could be extracted with some work to remove node dependencies, but they currently also depend on node apis.

@NullVoxPopuli
Copy link
Author

One thing I'm trying to figure out, and kinda gave up on last night (for now?) is finding the object in the output-json that represents a Reference.

like in Foo<X>, what is actually X?
I know this points at the symbolIdMap, but that has a sourceFilepath, which doesn't matches to the file paths in sources[].filePath, so I figure there must be some other way.

This is the code I was last trying: https://github.com/universal-ember/kolay/pull/43/files#diff-e67be3ef957214cba90a21f8bcc80542a449df7086fb062c8b933ab4ee76a24aR9
(apologies for the any usage all over the place, but I also couldn't figure out the types of the JSON structure, and I'm fairly certain that everything I have type-wise around the JSON output is wrong 😅 )

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 21, 2024

Don't have time to look at your code tonight, but https://typedoc.org/api/modules/JSONOutput.html has interfaces which describe the output.

X is probably a reference type. How it shows up in the json depends on if it has been resolved or not. If it includes a numeric target, that is pointing to a serialized reflection, it isn't pointing at the symbol ID map.

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Mar 24, 2024

I spent a bit of time looking at your code... and I'm not sure what you're actually trying to do. getSignatureType implies you're looking for call signatures but it looks like you're actually trying to get the first type argument? Maybe "signature" has some special meaning in your domain...

In the case of (extendedType as any).target.sourceFileName existing, the reference is pointing to some type which is not included in the doucmentation, so you can't resolve that reference.

@NullVoxPopuli
Copy link
Author

In my specific case, Signature is the name of the type that has has this shape:

interface Signature {
  Element: HTMLElement;
  Args: { ... };
  Blocks: { ... };
}

the reference is pointing to some type which is not included in the doucmentation, so you can't resolve that reference.

yeah, this kinda makes sense -- I've generated typedoc JSON from emitted declarations, rather than from source

what I'm trying to do with references, is in this situation:

export interface Signature { ... }

export default class Demo extends Component<Signature> { ... }

I want to get the type of Signature from Demo, like:

class Demo extends Component<Signature>
//                            ^ what properties are on this?

The Signature type is exported, so I figured it'd referenceable.


details, if you're curious 😅

but it looks like you're actually trying to get the first type argument
Maybe "signature" has some special meaning in your domain...

yeah, the base class I'm referencing only takes one type argument (or function, etc), I have these situations where I'm trying to obtain the type:

class extends Component<?> { }
class extends Modifier<?> { }
class extends Helper<?> { }
const a = modifier<?>(() => {})
const b = helper<?>(() => {})
const c = resource<?>(() => {})

and I'm not sure what you're actually trying to do

at a super high level, I'm trying to generate nice looking type docs for known shapes of types/interfaces -- examples here (where "not currently supported" means I couldn't figure it out):

I spent a bit of time looking at your code

I appreciate your time!! <3

@Gerrit0
Copy link
Collaborator

Gerrit0 commented Apr 6, 2024

The Signature type is exported, so I figured it'd referenceable.

It will be - if it is exported from your entry point. I suspect whatever is passed to TypeDoc only exports the wrapping class from the entrypoint.

It looks like cloning your repo and pnpm i, pnpm build isn't sufficient to get up and running, so I can't really provide any more insight here

I am interested in someday providing a minimal bundle that can be included in browser builds, but from a quick skim to refresh my memory from the last time I looked at this... getting that is probably more than an afternoon of work.

@Gerrit0 Gerrit0 changed the title Are there runtime traversal utils available for browser usage? Runtime traversal utils for browser usage Jun 9, 2024
@Gerrit0 Gerrit0 added enhancement Improved functionality and removed question Question about functionality labels Jun 9, 2024
@Gerrit0
Copy link
Collaborator

Gerrit0 commented Jun 9, 2024

Converting this to a feature request, will probably be 0.27... december-ish?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improved functionality
Projects
None yet
Development

No branches or pull requests

2 participants