Phuein

Improving API Browsing

Recommended Posts

I'm new to BJS, so I'm using the docs to learn. I've noticed some typos, so I forked the docs github and pushed fixes. Nice and simple.

However, when using the API to find more info about classes or methods, it's a pain to scroll through and seek the right one. Even with a page-search (ctrl+f) there's multiple partial results.

So, I wondered if I could add Alphabet linking to Classes, Properties, and Methods - the big lists. So, the top of each list has A, B, C... Z. You click H, and you see all that start with H. Each letter group has a minimalist separation from the others. I searched the github for where to edit and how, but got lost.

Is this possible with the currently used typedocs? Any tips on how to do it? I've read from the typedocs website already, and searched about the docs github, to no avail.

Share this post


Link to post
Share on other sites
On 8/6/2018 at 11:42 AM, Deltakosh said:

I'm not an expert of TypeDoc but this seems unlikely to me :(

Tsk. Would the person who setup the TypeDoc for BJS know anything about this? Can you tag them? This seems doable but non-trivial.

Share this post


Link to post
Share on other sites

Because we talking about API doc improvement, is there a way to download a local version of the API  (without having to build or compile or whatever not easy for a non-dev) ? In the same way of Blender Python API for example:

PuBLrPj.png

This allow very fast access & searches ('cause sometimes I have to wait the loading/reloading and that's frustrating when you just want to check a little thing).

Share this post


Link to post
Share on other sites
1 hour ago, V!nc3r said:

without having to build or compile

I apologize if this is too far off topic, but I wanted to share an option for API offline viewing that does not require build/compile - at least it may help people in the meantime.


I didn't see a way in TypeDoc to generate a full ZIP.  Obviously this is a more involved answer and possibly not for non-devs, but I just want to add that really the best documentation is the source that TypeDoc uses to generate the API docs.  In 2 steps:
1. https://github.com/BabylonJS/Babylon.js/ click download ZIP (or use git -  more difficult to setup, but makes it easy to update your local copy)
2. in VS Code open folder where you unzipped source from #1.

If you don't know where a class is hit "ctrl-t" and type the name.  ie: "environ" will show:
image.thumb.png.2eee53b4d629b5782e697457fd405b13.png

Enable the "outline" (option enabled by right-click on top Explorer bar) - can also use ctrl-shift-o. When you open ie: /src/babylon.scene.ts or Ctrl-T "scene" - you can see the full API (and hidden/private stuff as well that are NOT part of API) in the Outline.  Click the function (ie: createPickingRay) and it brings you right to the source code and API doc in the description.  You can click on methods in the source to navigate, find usages, etc..  It's a bit more work, but very fast and portable. With a couple of hotkeys it's the API + Internals. If you need some offline viewer in the meantime while there is no .ZIP download for docs maybe it will work for you! :)

image.thumb.png.36125eaf6272e82c4d0a340aeee66138.png

Share this post


Link to post
Share on other sites

Interesting, I will test that.

However, it's still less convenient that only html static pages (cloning a github repo' can be easy to do thanks to Github Desktop - but needs a github account, and Visual Studio isn't opening as fast as an already opened browser) ; but it looks like allowing quick searches when all is set up ;)

[edit] erf, my note about github account needed is wrong, 'cause as you say we can dl the zip directly

Share this post


Link to post
Share on other sites

After figuring out another issue with the docs (adding "Defined in" to API), I felt emboldened to try to figure this feature request once more.

So I spent a few hours. TypeScript... TypeDoc... Grunt... Handlebars....... Okay. So, between the code being in TS (which I don't use) and abstracted even further with Handlebars, I can't even perform basic JS operations on the site. Not without creating a further step that adds my JS into the compiled docs pages, which seems like terribly bad practice.

<rants> What an abstraction nightmare. Taking something simple like JS and turning it into a whole bunch of new API's. ><"

Any idea how I could add a Handlebars Helper function to, and I'm broadly assuming, /typedoc/babylon.d.ts? With that I'd be able to add JS controls to the template file /typedoc/default/partials/index.hbs, which would let me add the nifty index by letter. :D

Share this post


Link to post
Share on other sites

@Phuein This topic is not super old and maybe is abandoned, but I have actually been working a bunch lately on using the TypeScript compiler to do static analysis on the BabylonJS codebase.  You might end up having some luck writing your own stuff straight-up with the compiler (from typings .d.ts or source).  It is definitely fun to be generating with a compiler!!  I am dynamically generating code from the BabylonJS source for another project.  I think it would be not much more work to generate HTML instead of TypeScript (I am generating TypeScript).  I am able to get all the JSDoc/parameters/classes/methods/etc.  The only snag I hit so far was an interface extending a class in https://github.com/BabylonJS/Babylon.js/blob/master/src/Lights/babylon.shadowLight.ts.  Huuh - wuut???  That is not possible in the languages I am more familiar with like C#/java, but 100% allowed in TypeScript.  I have a PR that is accepted  (https://github.com/dsherret/ts-simple-ast/pull/483) for the compiler API wrapper I'm using.  If you want all the code I am using to parse BabylonJS hit me up (it's ~500 lines).  Be prepared for some pain on the way and rejoicing in the end.  Cheers.  Maybe write your own TypeDoc that is extendable :)

Share this post


Link to post
Share on other sites

I gave up on this idea for the time, yes. Nobody responded with a solution for adding Handlebars Helper functions, which is where I draw my line of bothering with this broken system. (Not being able to add simple JS to a webpage after hours of work means it's broken.)

I'm not following you. How is anything you're saying solving this issue? Why do I need to parse BJS for this? Can you provide code that helps with the actual issue? I definitely don't want to write my own TypeDoc, that would be a waste of my time. I was looking to add a very small and simple letter-index to the existing docs, only.

Share this post


Link to post
Share on other sites
8 hours ago, Phuein said:

How is anything you're saying solving this issue?

If the end result is API docs with letter groups then there are may possible solutions.  One is to generate the HTML from the source and it's not difficult.  I am going to be generating markdown for my project from BJS source and it will be trivial to add letter groups - like I don't think it would even take an extra hour.   I don't have a solution for TypeDoc - I haven't used handlebars for over 6 years.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.