<FromGitter>
<sam0x17> rustdocs handles this particularly well
<FromGitter>
<sam0x17> might be something to copy
<FromGitter>
<asterite> we need a way for shards to say where is the doc API url, then we'll be able to do interlink
<FromGitter>
<watzon> Why not just give the generator the ability to run in the lib folder as well?
<FromGitter>
<sam0x17> ^ the latter is what rustdoc does
<FromGitter>
<sam0x17> that also has the advantage of pinning to the exact correct revision of all the libs
<FromGitter>
<sam0x17> even if one was force-pushed
<FromGitter>
<sam0x17> (since then)
<FromGitter>
<watzon> It has certain advantages
<FromGitter>
<watzon> For instance in my case
<FromGitter>
<watzon> Every part of Cadmium is in the Cadmium namespace
<FromGitter>
<watzon> So the generator should be able to keep everything grouped together under that namespace in the docs, even though their in separate shards
<FromGitter>
<sam0x17> exactly
<FromGitter>
<sam0x17> on that note, I was thinking last night my idea about automatically generated bindings from arbitrary rust crates could be facilitated by crawling docs pages to figure out what methods to generate
<FromGitter>
<sam0x17> rust is super easy to FFI via crystal
<FromGitter>
<sam0x17> so basically autogenerate crystal versions of all public structs (and traits as modules) in the crate, and then autogenerate the FFI code to call/use those from crystal
<FromGitter>
<sam0x17> much easier to write something that crawls docs.rs than to write something that parses rust code (or adapt the compiler) xD
sagax has quit [Ping timeout: 244 seconds]
<FromGitter>
<watzon> Interesting
<FromGitter>
<watzon> Speaking of versioning that's another thing the doc generator needs to support
livcd has quit [Ping timeout: 246 seconds]
alex`` has quit [Ping timeout: 245 seconds]
chemist69 has quit [Ping timeout: 264 seconds]
chemist69 has joined #crystal-lang
<FromGitter>
<galvertez> is there anything special about `<library module name>::VERSION` that requires it to be a string? i.e. does shards use it or
DTZUZU has quit [Ping timeout: 272 seconds]
mistergibson has quit [Quit: Leaving]
lvmbdv has quit [Ping timeout: 258 seconds]
lvmbdv has joined #crystal-lang
lvmbdv has quit [Ping timeout: 244 seconds]
DTZUZU has joined #crystal-lang
flaviodesousa has joined #crystal-lang
<FromGitter>
<watzon> @galvertez no it's just a convention that's a holdover from Ruby
sagax has joined #crystal-lang
alex`` has joined #crystal-lang
lvmbdv has joined #crystal-lang
<FromGitter>
<asterite> So every shard doc will include docs for transitive dependencies, including the standard library? How do you find out what types are provided by the actual library and not its dependencies? Maybe separated somehow in the left side bar?
<FromGitter>
<asterite> And how to avoid including the entire standard library in every shard?
DTZUZO has quit [Ping timeout: 244 seconds]
<FromGitter>
<ArtLinkov> Hey all, A question regarding pgsql ⏎ How do I make a query that returns a multi-row object? (I mean without iteration of the query with "something" do |rs| etc...) ⏎ I tried using json serialization, but it only works for queries that return a single row ⏎ example: ⏎ ... [https://gitter.im/crystal-lang/crystal?at=5d63bade4b1189084e687ec5]
<FromGitter>
<andrius> Hello, curious what macro arguments shall I use, I want to list embedded classes. Lines 10 and 15: https://play.crystal-lang.org/#/r/7gcv
<FromGitter>
<j8r> Don't know if it's possible to list a subclasses of a module/class
<FromGitter>
<j8r> it is, wait
<FromGitter>
<alehander42> @sam0x17 maybe rust exposes a parser
<FromGitter>
<alehander42> most modern languages come with some builtin way to parse themselves
<FromGitter>
<Blacksmoke16> i dont think you can get classes that include a given module
<FromGitter>
<alehander42> which is better than scraping docs
<FromGitter>
<alehander42> (if not, i agree your idea sounds better)
<FromGitter>
<andrius> @Blacksmoke16 but subclasses/structs included within a class?
<FromGitter>
<Blacksmoke16> i.e. you want an array of all classes that inherit from a parent class?
<FromGitter>
<Blacksmoke16> then what @j8r linked would do the job
<FromGitter>
<Blacksmoke16> there is also `all_subclasses` that includes subclasses of the direct subclasses
<FromGitter>
<alehander42> in anyway, one would need to write the parser in rust itself (or to just expose the parser crates to crystal and write one then), but it should be possible, you can also look at treesitter: iirc it is used succsefully in nim for autogenerating wrappers
<FromGitter>
<j8r> note the first isn't exactly what you want
<FromGitter>
<j8r> @andrius updated, returns exactly what you want. A bit ugly. For some reasons it doesn't compile online, but locally it works: `{{@type.subclasses.map {|t| t.constants.map { |sub| (t.stringify + "::" + sub.stringify).id } } }}`
<FromGitter>
<j8r> in the `subclasses` class method
<FromGitter>
<asterite> @ArtLinkov I think it's `db.query_all "...", as: Response`
<FromGitter>
<Blacksmoke16> what about `Array(Response).from_rs(db.query "SELECT * FROM table;")`
<FromGitter>
<Blacksmoke16> :shrug:
DTZUZO has joined #crystal-lang
<FromGitter>
<ArtLinkov> @asterite It works! Thanks! ^^
<FromGitter>
<ArtLinkov> As a side note, I coudln't find 'db.query_all' anywhere... I think the Database docs could be made a bit better :)
<rkeene>
What's the PKCS#11 story like on Crystal ? Just let OpenSSL do it, or is there a library that helps ?
<FromGitter>
<asterite> @naqvis awesome!
<FromGitter>
<naqvis> Thank you @asterite
sorcus has quit [Quit: WeeChat 2.5]
sorcus has joined #crystal-lang
<FromGitter>
<bew> @bcardiff your tweet about unit types, I don't get it is it a new thing?
sz0 has quit [Quit: Connection closed for inactivity]
<FromGitter>
<bcardiff> @bew you could say it's a new usage of existing features. While playing with something like unit types, typing `TheUnitType.new` seems redundant. Why we can't type only `TheUnitType` and use it as a value. It turned out that you can. `module TheUnitType; extend self; end;` Then the module turned out to be a value of its own type.
<FromGitter>
<watzon> Very cool @naqvis
<FromGitter>
<watzon> may actually use that at some point
<FromGitter>
<j8r> @sam0x17 It reminds me something, I may have seen it before. Definitely handy and powerful indeed
sagax has quit [Ping timeout: 272 seconds]
sagax has joined #crystal-lang
<FromGitter>
<naqvis> thank you @watzon
<FromGitter>
<absolutejam_gitlab> wait, so is a module a type/
<FromGitter>
<watzon> @absolutejam_gitlab what do you mean?
<FromGitter>
<Blacksmoke16> they can be used as an interface yes
<FromGitter>
<Blacksmoke16> anything that includes a module is also that module
<FromGitter>
<Blacksmoke16> depending on the context, sometimes inheritance makes more sense, others (if its just a mixin for example, like `Comparable`) then a module makes more sense
<FromGitter>
<absolutejam_gitlab> I like to think of inheritance as pretty vertical but an interface is more horizontal, in that you can just add it in to an existing Class and have it work with a method
<FromGitter>
<absolutejam_gitlab> and if you're not in control of the class
<FromGitter>
<Blacksmoke16> inheritance is good when there is common logic that is shared between types, and each child is just implementing the logic specific for that type
<FromGitter>
<Blacksmoke16> i also like inheritance since you can get the children at compile time
<FromGitter>
<Blacksmoke16> which you cant do with modules/annotations (yet)
<FromGitter>
<Blacksmoke16> then, for the cases where the children dont share common logic, i.e. inheritance isnt needed, could just get the array based on types annotated with x
<FromGitter>
<Blacksmoke16> but yea, is quite slick
<FromGitter>
<tenebrousedge> I wish Crystal had a `method` method
<FromGitter>
<tenebrousedge> in real code, I find that wanting to do this is often a mistake, where the method should actually be defined elsewhere
<FromGitter>
<tenebrousedge> but it's not always convenient to do so
<FromGitter>
<tenebrousedge> `method` should probably be doable, at least as a macro
<FromGitter>
<tenebrousedge> I think it needs some form of `send`
<FromGitter>
<kinxer> I messed with this a little and I can see why you're unhappy with what exists. This is what I got (probably even less performative than @watzon's solution: https://carc.in/#/r/7ghu/edit
<FromGitter>
<tenebrousedge> actually that's probably not bad performance-wise
<FromGitter>
<kinxer> And if you don't need `ALPHABET` to be an array in the first place, https://carc.in/#/r/7ghw
<FromGitter>
<tenebrousedge> yes, sets work for that
<FromGitter>
<tenebrousedge> but the problem isn't relevant
<FromGitter>
<kinxer> Ah... So this doesn't work for your actual use-case, then?
<FromGitter>
<tenebrousedge> just a convenient way to discuss the syntax
<FromGitter>
<tenebrousedge> I also don't (currently) have a real use-case, it's just something that I often want to do, that only half-works