jhass changed the topic of #crystal-lang to: The Crystal programming language | https://crystal-lang.org | Crystal 0.35.1 | Fund Crystal's development: https://crystal-lang.org/sponsors | GH: https://github.com/crystal-lang/crystal | Docs: https://crystal-lang.org/docs | Gitter: https://gitter.im/crystal-lang/crystal
deavmi has quit [Ping timeout: 272 seconds]
<oprypin> watzon, how are things going with mkdocstrings?
oprypin has quit [Quit: Bye]
oprypin has joined #crystal-lang
<FromGitter> <watzon> @oprypin going well thusfar. I am having an interesting problem though and wondered if you knew the solution.
<oprypin> watzon, so nav is just not defined?
<FromGitter> <watzon> This is what happens when I have a `Tourmaline.md` and a `Tourmaline` directory, but if I have an `index.md` in the Tourmaline directory I end up with `Tourmaline/Index`
<FromGitter> <watzon> Yeah I didn't set a custom nav. Is there anyway to make it auto populate directories like it does by default?
<oprypin> watzon, probably need https://github.com/oprypin/mkdocs-section-index . clickable sections are very much non standard, just i've been pushing this :D
<oprypin> things work without defining nav but eventually you'll probably want to define some kind of order for your things, right?
<FromGitter> <watzon> Look at you with all your plugins
<oprypin> been busy 😳
<FromGitter> <watzon> I couldn't tell lol
<FromGitter> <watzon> Thanks for the help. Docs have been a sore point in Crystal with me for a long time.
<oprypin> :>
<oprypin> can someone tell me, is this color really as ugly as it seems to me? https://oprypin.github.io/crsfml/api/SF/Image.html
<FromGitter> <watzon> It's pretty harsh
<oprypin> mkdocs-material just doesnt seem to have any good option for green color
<FromGitter> <watzon> Can you not set your own?
<FromGitter> <watzon> Ahh beat me
hmmm has quit [Quit: WeeChat 3.0]
<oprypin> omg Pygments with my fix will be released soon too. everythings coming together
<FromGitter> <watzon> Do you know of a way to do a custom nav, but not have to manually define every single one of the auto generated pages?
<oprypin> watzon, you won't believe what my reply will be
<FromGitter> <watzon> You have a plugin lol
<oprypin> watzon, for the nav it's https://github.com/oprypin/mkdocs-literate-nav#user-content-nav-cross-link:~:text=let%20it%20be%20inferred
<oprypin> and if you want to also auto generate the actual ::: doc pages , there's a plugin for that too
<oprypin> watzon, you'll find all these in https://github.com/oprypin/athena-website/compare/mkdocstrings
<oprypin> https://github.com/lukasgeiter/mkdocs-awesome-pages-plugin is a longer standing alternative to mkdocs-literate-nav
Volk has quit [Quit: See you next time!]
Volk has joined #crystal-lang
<FromGitter> <watzon> You're the best dude. This is going to make for such better docs.
<oprypin> aww 😊😊
<oprypin> gimme some stars on github πŸ₯Ί
<FromGitter> <watzon> Can definitely do that
<oprypin> 😊
<FromGitter> <Daniel-Worrall> I'd love to see some support for hosting docs for multiple platforms and even feature flags. docs.rs does this
<FromGitter> <Daniel-Worrall> supplied by shard.yml or on the cli
deavmi has joined #crystal-lang
<FromGitter> <watzon> @oprypin have you tried using literate-nav and section-index together with multiple nested directories?
<FromGitter> <watzon> For instance, I have ⏎ ⏎ 1) api_reference/String/index.md ⏎ 2) api_reference/Tourmaline/index.md ⏎ and a whole bunch of other files and directories being generated inside of `api_reference/Tourmaline` [https://gitter.im/crystal-lang/crystal?at=5ff670bd14cec811ec81e2f4]
<FromGitter> <watzon> My `SUMMARY.md` looks like this ⏎ ⏎ ```* [Getting Started](index.md) ⏎ * [API Reference](api_reference/)``` [https://gitter.im/crystal-lang/crystal?at=5ff670e84498e01bbf908724]
<FromGitter> <watzon> But I end up with this
<oprypin> watzon, sure, i combine them on almost every site
<FromGitter> <watzon> Any idea what my problem might be then? As things are right now it's not generating anything under API Reference
<oprypin> i dont know what's happening. some guesses: did you specify `literate-nav: nav_file`?
<oprypin> are the files actually there under api reference? can you visit them directly via url?
<FromGitter> <watzon> Yes and yes. `nav_file` is set to `SUMMARY.md` and the files are accessible
<oprypin> oh well that sucks. would love to see the whole repo
<FromGitter> <watzon> I can commit my code and push it. Sec
<FromGitter> <watzon> I'd love to see if you can figure it out. Likely I'm just doing something wronf.
<oprypin> thanks
<oprypin> ok first thing i see is that it works. and i think i have my guess
<oprypin> yes
<oprypin> watzon, https://github.com/oprypin/mkdocs-literate-nav/tags you have v0.2.0 which apparently i forgot that it's too shitty. need v0.3.0b1 . which is pip install -U --pre but i think you have your other way
<FromGitter> <watzon> Ahhh ok. Just need to figure out how to do that with pipenv.
<FromGitter> <watzon> You're the real MVP my friend
<FromGitter> <watzon> It's working as expected now
f1reflyylmao has quit [Ping timeout: 268 seconds]
f1refly has joined #crystal-lang
hightower2 has quit [Ping timeout: 246 seconds]
avane has quit [Quit: ZNC - https://znc.in]
avane has joined #crystal-lang
Volk has quit [Quit: See you next time!]
_ht has joined #crystal-lang
<FromGitter> <watzon> Hey @oprypin, for some reason I'm not getting constant values in my docs, just the name of the constant. Is that intentional?
<FromGitter> <Dan-Do> is there any different between LLVM 8.0 and 10.0?
<FromGitter> <Dan-Do> I am using Fedora, which is only 8.0, while macOS is 10.0
<FromGitter> <Daniel-Worrall> https://carc.in/#/r/a8al is there any way I can get this to work without specifying the Foo namespace `Foo.bar`
<FromGitter> <HertzDevil> `include Foo` inside `Baz`
_whitelogger has joined #crystal-lang
hmmm has joined #crystal-lang
hmmm has left #crystal-lang ["WeeChat 2.8"]
deavmi has quit [Read error: Connection reset by peer]
deavmi has joined #crystal-lang
<FromGitter> <erdnaxeli:cervoi.se> Hi, how can IΒ access from a macro to the type where the macro was called?
<FromGitter> <erdnaxeli:cervoi.se> or should I juste include a module and use the "included" macro?
<FromGitter> <anapsix> greetings! ⏎ some time ago, I've noticed Time::MonthSpan was not comparable, and made a PR (https://github.com/crystal-lang/crystal/pull/10072) ⏎ any chance I could any feedback on it?
<straight-shoota> anapsix, seems I have missed that one. The general idea is to drop MonthSpan for a more generic, more granular calendrical duration type.
<straight-shoota> might still be worth merging that short term
<FromGitter> <erdnaxeli:cervoi.se> what IΒ am missing about instance_vars? https://carc.in/#/r/a8ea
<straight-shoota> Instance vars are only resolved after *finished* hook
<straight-shoota> this is a chicken and egg problem
<straight-shoota> you would expect the hook to have ivars available but also be able to add new ones, but that would disrupt the already resolved ones
<FromGitter> <erdnaxeli:cervoi.se> hmm ok, thanks
<straight-shoota> you can work around that by delegating to a method because at the time methods are instantiated, ivars need to be resolved
<straight-shoota> https://carc.in/#/r/a8ea
<FromGitter> <jrei:matrix.org> @watzon you prefer Telegram than Matrix?
<FromGitter> <anapsix> so that would work https://carc.in/#/r/a8ej @erdnaxeli:cervoi.se
<FromGitter> <erdnaxeli:cervoi.se> it does, thanks!
<FromGitter> <erdnaxeli:cervoi.se> and when including a module, @type in the method refers to the including type, so everything is cool 😎
<FromGitter> <anapsix> I helped?
<FromGitter> <erdnaxeli:cervoi.se> you did, thx @anapsix and @straight-shoota
<FromGitter> <anapsix> πŸŽ‰ πŸŽ‰ πŸŽ‰
<FromGitter> <anapsix> that's it, 2021 is good.. the end.. please.. no more
<FromGitter> <erdnaxeli:cervoi.se> ^^
ua_ has quit [Quit: Leaving]
Volk has joined #crystal-lang
ua has joined #crystal-lang
ua has quit [Ping timeout: 246 seconds]
ua has joined #crystal-lang
hmmm has joined #crystal-lang
hmmm has quit [Client Quit]
deavmi has quit [Ping timeout: 272 seconds]
deavmi has joined #crystal-lang
<FromGitter> <domgetter> Is there a way to have custom error messages using YAML::Serializable ?
<FromGitter> <Blacksmoke16> error messages in regards to what?
<FromGitter> <domgetter> Like if a yaml file doesn't include a key that is expected or a list is empty or something like this
<FromGitter> <Blacksmoke16> hmm, not without reimplementing the parsing
<FromGitter> <Blacksmoke16> an empty list sounds more like validation after deserialization tho
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<FromGitter> <domgetter> Okay if that's where the logic is intended to go, then that's fine. Thank you
<FromGitter> <Blacksmoke16> because en empty array is valid even if it may not be according to your domain logic
<FromGitter> <Blacksmoke16> possibly could use a custom converter to include some stuff in but :shrug:
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
HumanG33k has quit [Remote host closed the connection]
HumanG33k has joined #crystal-lang
<oprypin> [09:50:51] <3176b3@watzon> Hey @oprypin, for some reason I'm not getting constant values in my docs, just the name of the constant. Is that intentional?
<oprypin> yes. not sure about that decision but rest assured it's not a problem to implement
<oprypin> also not even a problem to make it configurable. do you have any reason that it should be there? there have been past debates
<straight-shoota> why would you *not* show the value?
<straight-shoota> for some constants the actual value may be irrelevant, but more often than not it has semantic meaning and you would want to document the value anyways
<FromGitter> <watzon> @oprypin just makes sense to have the value in my opinion. Why even mention the constant otherwise?
Volk has quit [Quit: See you next time!]
HumanG33k has quit [Ping timeout: 256 seconds]
sampope has joined #crystal-lang
<sampope> Hi, i have a question about fibers/channels and if my understanding is correct. I want to make 10+ sql queries concurrently, like this https://dpaste.com/BBY35UPJ3 am I correct in understanding that the variable = channel.receive will be in the correct assignment and not whichever fiber finishes first? meaning in that code sample, total_ip_by_month and unique_ip_by_month won't be mixed up/crossed?
<sampope> some queries are going to take far longer than others, but my current code executes everything serially
<FromGitter> <watzon> So channel.receive will always get the first thing to come into the channel, so if you're executing 10 queries concurrently and then sending the result through the channel they most likely won't be in order. You can always send the result with an index though, that way you can put things back into order.
<FromGitter> <watzon> So your channel would look like `Channel(Tuple(Int32, DB::ResultSet)).new(10)` or something.
<sampope> i thought it was too simple to just channel.send and channel.receive and it would all work out
<FromGitter> <watzon> Yessir lol. A wee bit too simple.
HumanG33k has joined #crystal-lang
<sampope> channel.receive doesn't take arguments, which was my first thought, just channel.receive(total_ip) or something
<sampope> thank you
<Andriamanitra> you could use multiple channels
<Andriamanitra> then total_ip.receive and unique_ip.receive
<FromGitter> <watzon> That you can as well, if you wanted to pair each query up with a channel and then receive them in order.
<FromGitter> <watzon> Really depends on if you want to be able to process each result as soon as it's available or not
<sampope> i didn't even think of multiple channels
<sampope> i'm so used to using ruby's parallel gem that having to do concurrency myself is new
<FromGitter> <watzon> Yeah I'm working on recreating some of that. Actually this might be of use to you: https://github.com/protoncr/async
<Andriamanitra> also couldn't you do that with a single query `SELECT COUNT(ipaddr), COUNT(DISTINCT(ipaddr))`?
<FromGitter> <watzon> I don't believe the `Future.all` method returns things in order right now, but I should be able to make that possible.
<sampope> @Andriamanitra yes, i could, but for learning purposes, i'm trying to keep it simple so i can watch the db and see the queries executing concurrently
<sampope> watzon: looks interesting
hightower2 has joined #crystal-lang
_ht has quit [Remote host closed the connection]
<FromGitter> <watzon> @sampope `Future.any` now returns futures in the order they're given
<FromGitter> <watzon> ```code paste, see link``` [https://gitter.im/crystal-lang/crystal?at=5ff77e48252c0a6dedf77b70]
<FromGitter> <watzon> Of course you could always do something like this yourself as well
<sampope> cool, i'll get there eventually
<FromGitter> <watzon> @oprypin is there a syntax for easily linking to a namespace within a markdown file? For instance if I wanted to link to the page for `Tourmaline::Client` or something?
<oprypin> (2nd paragraph)
<FromGitter> <watzon> Oh nice! Thanks
Volk has joined #crystal-lang
sampope has quit [Quit: sampope]
<FromGitter> <watzon> I just realized that the `section-index` plugin isn't doing anything. Any idea why @oprypin? I just pushed a new version of https://github.com/protoncr/tourmaline
<oprypin> what the heck :s
<oprypin> no everything's correct
<oprypin> watzon, forget about section-index, you have bigger problems
<oprypin> CallbackQueryHandler.md is not the index for CallbackQueryHandler/*.md
<oprypin> CallbackQueryHandler/index.md is the index for CallbackQueryHandler/*.md
<FromGitter> <watzon> Wait, that's how it should be in the most recently updated version
<FromGitter> <watzon> This is what I have locally
<FromGitter> <watzon> Basically right now I'm just making every namespace type have a folder with an index.md inside
<oprypin> thats bad then. likeely it's about the ordering of plugins
<FromGitter> <watzon> I've tried to move section-index around, but I always get the same result
<FromGitter> <watzon> Oh apparently I needed to restart the server so it would clear the previous build
<FromGitter> <watzon> Seems to work now
<FromGitter> <watzon> After moving section-index to the bottom
<oprypin> sorry 'bout that. i had this on my mind but preventing this can only be done through hacks
<FromGitter> <watzon> So much better
<FromGitter> <watzon> No worries, just glad it works. This is looking awesome.
<FromGitter> <watzon> Now if I just had a way for it to show the value of constants it would be perfect
<FromGitter> <watzon> Constants also don't have a view source link below them. Not sure that I care as much about that though.
<oprypin> watzon, they dont in Crystal either, do they?
<oprypin> watzon, i will push a change to show constants. is it urgent?
<FromGitter> <watzon> No, which is partially why I don't think I care as much
<FromGitter> <watzon> Also no, not urgent. I don't plan to have the docs finished for a couple days anyway.
<FromGitter> <watzon> Just would be a nice to have
<FromGitter> <Blacksmoke16> value of constants deff show up in crystal docs
<FromGitter> <watzon> The value does, but a view source link doesn't
<FromGitter> <watzon> For whatever reason. Probably because the value itself is close enough.
<FromGitter> <Blacksmoke16> hm?
<FromGitter> <watzon> In the Crystal docs we get a value, but there isn't a "view source" link like with methods. Probably because the constant's value is the same as the source 98% of the time.
<oprypin> Blacksmoke16, there's no [View source] link under `TAG =`
<oprypin> there is the "defined in" for the whole type, though. i dont have that, yes.
<oprypin> watzon, crystal nightly will get you better docs btw. method parameter types will be linkified
<oprypin> i really should stop procrastianting on writing all of this down
<FromGitter> <watzon> @oprypin yeah that seems about right to me. Is there a setting for having method definitions appear as anchors like in the official docs?
<oprypin> dont understand
<oprypin> watzon, i think you're looking for https://github.com/oprypin/crsfml/blob/b1340884ca3fa78f466fbfc1a3eda93c34bf1622/mkdocs.yml#L28-L29. and make sure you've upgraded "mkdocstrings" past its beta release
<FromGitter> <watzon> So in the official docs there are `#` next to method definitions which anchor to that specific method on the page, that way I can easily copy a link directly to that method
<FromGitter> <watzon> For example, https://crystal-lang.org/api/0.35.1/BigInt.html#new(num:BigFloat)-class-method
<oprypin> then i guessed correctly ^
<FromGitter> <watzon> Ahh nice, so I just need to upgrade it seems
<FromGitter> <watzon> I'm at 0.14.0 currently, is there a newer version that I'm missing?
<FromGitter> <watzon> Ahh nvm, I messed up the formatting
<FromGitter> <watzon> I'll be waiting on that update btw, I want to change the size of the [View Source] link without changing the size of the rest of the comment content
<FromGitter> <watzon> :D
<oprypin> watzon, fine then :> released an update with both of the changes u wanted
<FromGitter> <watzon> Haha you're the best man. This is really exciting stuff for me. I like nice looking docs, and the default generator was not delivering.
<FromGitter> <watzon> This is looking beautiful
<oprypin> im so happy to hear that
<oprypin> up until the last moment i was like "what if everyone hates it"
<FromGitter> <watzon> Yeah no, it's great. Might be better if it was a "pure crystal" implementation so that we don't have to mix languages, but I really couldn't ask for much better right now.
<FromGitter> <watzon> Also there are definitely some benefits to using something that has already been in development for a while
<FromGitter> <Blacksmoke16> imo at some point you just have to accept the defacto standard might be in a diff lang
<FromGitter> <Blacksmoke16> e.g. i dont see benefit in putting effort into an E2E testing framework when Cypress is already really good :shrug:
<FromGitter> <Blacksmoke16> crystal framework*
<oprypin> watzon, seems like api reference could be a tab? https://squidfunk.github.io/mkdocs-material/setup/setting-up-navigation/#navigation-tabs
<FromGitter> <domgetter> Is there a syntax for destructuring a named tuple?
<oprypin> domgetter, no
<FromGitter> <Blacksmoke16> **?
<FromGitter> <Blacksmoke16> NVM, that's diff thing
<oprypin> ha i guess
<oprypin> `def foo(x, y, z); use x; end; foo(**namedtuple)` is a way to destructure all in all
<FromGitter> <watzon> Ooh good idea @oprypin
<oprypin> watzon, i dont know if you plan to migrate your main site to mkdocs, but in any case, i think another tab could just be a plain link to your main site
<FromGitter> <domgetter> Ah I was hoping there would be something like this for block parameter lists. So for example `shapes.each do {|(name, area)| ...}` or something like that
<oprypin> domgetter, no. and these should be structs
<oprypin> `shapes.each do {|s| use s.name, s.area}`
<FromGitter> <domgetter> I don't necessarily want these on the stack
<FromGitter> <Blacksmoke16> if you're using a named tuple they're already on the stack :p
<oprypin> domgetter, namedtuple and struct are exactly the same in terms of stackiness
<FromGitter> <domgetter> then why change it to a struct?
<oprypin> because namedtupls are not designed for this
<oprypin> the question is why use namedtuple
<FromGitter> <domgetter> because that's what the type of the literal is
<FromGitter> <domgetter> Unless there's a struct literal I don't know about
<oprypin> Shape.new(name, area)
<oprypin> ???????????????
<FromGitter> <domgetter> That's not a literal
<FromGitter> <Blacksmoke16> i think hes saying just dont use the literal and use that instead
<FromGitter> <Blacksmoke16> named tuples aren't something you should be using like you would a hash in ruby
<oprypin> can you not use a feature if it's not a literal? i dont get it
<FromGitter> <jrei:matrix.org> Namedtuples are a pain for types
<FromGitter> <jrei:matrix.org> How do you use it?
<FromGitter> <domgetter> How do I use a NamedTuple?
<FromGitter> <Blacksmoke16> `{name: "circle", area: 10}`
<FromGitter> <domgetter> Sorry, I meant, is j8r asking how I'm using one.
<FromGitter> <Blacksmoke16> you're using to store data to pass around yes?
<FromGitter> <Blacksmoke16> the question is why
<FromGitter> <Blacksmoke16> structs are superior to them in pretty much every way when used in this way
<FromGitter> <domgetter> Unless I'm being incredibly dense, I don't understand why I have to explain why I'm storing data and passing it around.
<FromGitter> <Blacksmoke16> you're of course free to do it however you want, but its jut not optimal to use structs
<oprypin> domgetter, question is why you're doing it in a strictly inferior way to using structs
<FromGitter> <Blacksmoke16> to use named tuples*
<FromGitter> <Blacksmoke16> granted if this data is mutable you should use a class instead, as named tuples and structs are intended to be immutable
<oprypin> domgetter, anyway if u think defining a struct itself is too long, maybe this will cross the convenience threshold https://crystal-lang.org/api/0.35.1/toplevel.html#record(name,*properties)-macro
<FromGitter> <jrei:matrix.org> @domgetter: try to type the arguments, you'll see :)
<FromGitter> <Blacksmoke16> also lose the ability to use inheritance, modules, custom methods etc