-
Notifications
You must be signed in to change notification settings - Fork 42
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
Generate typescript definitions & documentation for common GIR libraries #24
Comments
not sure if it helps, but I have created a GJS based CommonJS env called cgjs which brings in also a gir namespace scanner called cgjs-about cgjs-about gi.Gio.File
# output as json format
cgjs-about gi.Gio.File --json It provides all things it understands per each class, including optional arguments. Maybe from that JSON it's easy to create the |
Looks like there's a couple of projects that already try to do this: https://github.com/darkoverlordofdata/gir2dts |
Looks interesting! Although those are aimed at GJS bindings, which means the naming conventions are not the same as the ones we're using here. const win = new Gtk.Window({
window_position: Gtk.WindowPosition.CENTER // should be windowPosition
}) There is already lib/inspect.js, which would be a good starting point. It implements functions for exploring the GIR namespaces through javascript. E.g.: const inspect = require('./lib/inspect')
const gtk = inspect.parseNamespace('Gtk')
console.log(gtk.init)
// => FunctionInfo { type: 'function', ... } |
@romgrk the result would be the same, 'cause AFAIK the GIR namespace is the same in GJS or whatever Node.js is doing here, it's standard 🤷♂️ in cgjs I convert at runtime through proxies the accessor, mapping that to equivalent And yet, this has nothing to do with |
Hello, I'm interesting on generating TypeScript type definitions using ./lib/inspect . I have very basic knowledge of GTK and I?m not an expert on C++ but have plenty experience with TypeScript and in particular TypeScript type definitions for libraries. My plan is to start with lib/inspect.js, and when I see I can reach somewhere, start researching how to support also the jsdocs. I wonder know if someone is planning / working on this or if the project has any plan to support TS descriptions at all ? Thanks I see this project https://github.com/niagr/gjs-ts/blob/master/Gtk-3.0.d.ts has what's seems to be a complete type definitions for gtk+3 although I think the member camel/case conventions does not match this project's. It would be easy for build a small program to refactor these names to support this project's API, but I wonder what't the opinion on that take - or if it would be better to build a solution from scratch (that also considers jsdoc descriptions ?) |
As far as I know, no one is actively working on generating typedefs at the moment. Having TS descriptions would be SO awesome, I just haven't had enough time to do it myself :) If you want to take the task, you're more than welcome.
The naming is handled in lib/index.js, so that part is quite easy to use. It could be imported in Another thing to be mindful of is that event handlers don't have the self parameter as other GIR implementation have. widget.on('key-press-event', (self: Gtk.Widget, event: Gdk.EventKey) => {...})
// where widget === self in node-gtk, the self parameter is elided: widget.on('key-press-event', (event: Gdk.EventKey) => {...}) If you open a PR, I can try to list all the gotchas that I can think of. |
Working on it and this is more or less my plan :
types generation
Will keep you updated, thanks for the project, btw: do you know / have a working gdk-cairo test ? with time would be awesome to build a playground app with an editor on one side and the running app on the other and a list of examples - just compile and eval() the code on edit to reload the app - That should be an awesome gtk/cairo playground not so easy to implement with C I think. Thanks |
@cancerberoSgx Actually I want to do it ... but I'm not very good with typescript. It's great if you can help with that. I'm ready to help if you need. ✌️ |
@cancerberoSgx dont forget to join us on discord for discussion. 🙂 |
@cancerberoSgx gir has the docs/descriptions |
Hi im sorry but currenlty my desktop is mac which is not my favorite technology and until a moment everything was fine but now listLibs() is showing gtk+ version 2.0 (not 3.0) and is failing
I'm using this brew thing, and tried to remove everything and installing it again, but no luck - restarting.... Perhaps somebody knows some trick ? will try again but in the meanwhile perhaps somebody had the same trouble ? |
@benwaffle oh, nice to know - I read about that files(?) will research how to generated from the sources - will try with an old ones I imagine are easy to generate from latest sources right ? thanks! good tip |
@benwaffle form your repo https://github.com/nemequ/vala-girs/tree/master/gir-1.0 !! sorry I'm kind of rusty in native desktop technologies -... thanks |
Congratulations , you saved my day - Don't know why I didn't see these technologies before - Nice to see an initiative building on top of formal object descriptions and documentation! - https://valadoc.org/ and the value there is amazing - all those technologies ruled with the same ring... one little suggestion, from a total outsider - adding a link to download the .gir file that sourced each project could make sense. Congrats and thanks again! |
Lots of questions and I don't have much time for personal projects today ^^ I'll start with these two:
Do not hesitate if you have questions about GObject concepts. I've found it a bit hard to understand them sometimes so it helps to have someone who can explain them. |
Here is a fork from me of ts-for-gjs to add type definition generation support for node-gtk (including two examples). Btw here is also an interesting conversation about type definitions for node-gtk: clayrisser/ts-gir#1 |
The ts-for-gjs fork with initial support for node-gtk is merged (including examples) now, help for improvement is very welcome |
I've found a few issues that I've listed here. Thanks for your contribution! |
Guys, anything happening it that department? |
@padcom You can use ts-for-gir which has already very good results |
Nothing new here, |
There is quite news there, because there were a few code contributions to further improve the types for node-gtk on It is important not to use the package from NPM as this is not from us and is unfortunately heavily deprecated (but I will be releasing it officially on NPM under a different name soon), more about how to use ts-for-gjs in die README. Bug reports and other contributions are welcome. Currently I'm working on a big pull request gjsify/ts-for-gir#63 where I'm working on introducing real inheritance in the types. This is already working very well but I still need to fix some type conflicts. I would also be happy about contributions to this PR because it's not easy to fix this conflicts and maybe a new way of thinking will also help. The master branch currently does not use inheritance and simply copies all inherited methods, this has the advantage that it avoids the type conflicts, but has the disadvantage that the generated types become very large. By the way, I'm also working on another project in parallel to generate API documentation from this generated Typescript types: https://node-gtk-docs.gjsify.org/ As soon as my PR is finished I will improve the generated documentation as well. |
Okay now real inheritance and implementations are merged to ts-for-gir, I would be very happy if someone would test the types for node-gtk again :) |
I did a quick overview, here are a few notes:
That's it for the issues, I also wanted to say great work for the rest! It's really nice to be able to just switch the extension to |
No description provided.
The text was updated successfully, but these errors were encountered: