Ir al contenido principal

Ralsina.Me — El sitio web de Roberto Alsina

Coding in anger: not-gitbook

I have, in­ter­mi­tent­ly, for the past few month­s, been writ­ing a book. You can see it here and I am fair­ly hap­py with how it's go­ing.

I am not so hap­py with the tool­ing.

When I start­ed writ­ing it, I did­n't want to write a tool, I just want­ed to write a book. So, I looked for "things to make a book out of mark­down" and found a few, in­clud­ing md­Book and git­book and tried them both, then de­cid­ed to go with git­book be­cause it seemed more de­vel­ope­d.

But, you know how this work­s. Things start­ed drift­ing.

One ini­tial ob­sta­cle was that I want­ed the code in the book to come from the ac­tu­al work­ing code, not be a copy. I al­so want­ed to "ex­e­cute" the chap­ters and make the out­put of the chap­ter's code part of the chap­ter itelf.

I found a nice tool for this called pyLit­er­ate which... I end­ed up ex­tend­ing to al­low for things such as "in­clude this piece of code from that file but do not ex­e­cute it" and what­ev­er, and in­te­grat­ing it in­to git­book in­volved ... a lot of Make­files.

And then wen the out­put ap­peared in git­Book ... I re­al­ly did­n't like how syn­tax high­light­ing worked. I want­ed pret­ti­er and specif­i­cal­ly to be able to high­light some lines, and to have line num­bers match­ing the file con­tents and not start­ing from 1 ... and I end­ed up writ­ing a Git­book Ex­ten­sion

And I added sup­port for graphviz in pyLit­er­ate be­cause I want­ed SVG di­a­grams as part of the code and not as sep­a­rate things.

And I wrote and I wrote.

And then life hap­pened and I stopped writ­ing. And when­ev­er I want­ed to start writ­ing again in a new set­up some­thing broke.

  • Maybe the git­book ver­sion in­stalled or its de­pen­den­cies had a se­cu­ri­ty is­sue and need­ed up­dat­ing.
  • Maybe the up­dat­ed git­book broke my plug­in
  • Maybe things just were "of­f" and I had to track it down*

And a cou­ple of days ago, I just got an­gry. And what the hell this is just a lame stat­ic file gen­er­a­tor and I know those suck­er­s.

So, I de­cid­ed to see how much work would it be to reim­ple­men­t, some­what dumb­ly, git­book.

Well, re­al­ly, it's about a day's work (for a low qual­i­ty ver­sion)

  • Sup­ports all I want
  • Sup­ports plug­ins
  • Sup­ports ar­bi­trary mark­down pre­pro­cess­ing
  • Sup­ports ar­bi­trary mark­down ren­der­er hack­ing
  • Us­es mis­tune for mark­down, which kicks ass
  • Us­es jin­ja2 for tem­plates and they are 10x sim­pler than in git­book AND THE OUT­PUT LOOK THE SAME. I mean, there is one tem­plate

I logged the work, which was at a very re­laxed pace over a cou­ple of days here and pub­lished not-git­book in git­lab

I could mi­grate my book to the new toolchain in a day more work, most­ly in­volv­ing im­ple­ment­ing things git­book does­n't do and I am hack­ing via Make­files.

It's sure­ly not ready for any re­al us­age but feel free to poke around and con­tact me if you want to use it.

Out on Blue Six

Cover for Out on Blue Six

Review:

Had a bit of a hard time fin­ish­ing the book. At a cer­tain point around 2/3rds of the way in the lan­guage got just too flow­ery and psy­chodel­ic.

In any case, it's pret­ty good!

The Bone Clocks

Cover for The Bone Clocks

Review:

So good.

The au­thor has a great ear for the tone of a time and place. The end is pret­ty heart­break­ing.

DeVicenzo 2

A long time ago I "wrote a web browser". Those there are some very heavy quotes. You may imag­ine me do­ing air quotes while I write it, may­be?

That's be­cause I did­n't re­al­ly, what I ac­tu­al­ly did was write UI around Qt's we­bkit-based wid­get. It was a fun pro­jec­t, spe­cial­ly be­cause I did it with the ab­surd con­straint of stay­ing be­low 128 lines of code.

And then I did not touch if for six years. But yes­ter­day I did.

commit 0b29b060ab9962a32e671551b0f035764cbeffaa
Author: Roberto Alsina <ralsina@medallia.com>
Date:   Tue Oct 30 12:32:43 2018 -0300

    Initial PySide2 port

commit 831c30d2c7e6b6b2a0a4d5d362ee7bc36493b975
Author: roberto.alsina@gmail.com <roberto.alsina@gmail.com@1bbba601-83ea-880f-26a2-52609c2bd284>
Date:   Fri Jun 1 15:24:46 2012 +0000

    nicer, smaller margins

Six years is a long time. So, nowa­days:

  • I pre­fer my code to be for­mat­ted bet­ter
  • Python 3 is the thing
  • Py­Side is of­fi­cial, so I would rec­om­mend us­ing it in­stead of PyQt
  • Qt is now on ver­sion 5 in­stead of 4

So, with those new con­straints in mind, I port­ed De­Vi­cen­zo to the lat­est ev­ery­thing, for­mat­ted the code prop­er­ly us­ing black, and ex­pand­ed by line lim­it to a gen­er­ous 256.

And Here it is ... it's not re­aly use­ful but it is an ex­am­ple of how ex­pres­sive the Python/Qt com­bi­na­tion can be, even while be­ing an ab­surd­ly bad ex­am­ple no­body should fol­low (O­h, the lamb­das!)

screenshot


Contents © 2000-2023 Roberto Alsina