Taeluf Devlog, Feb 20, 2021

It's Saturday! Which is my Friday, so I'm excited for the weekend! :D Not super feeling code today, but it's 10:15am & a good time to get started. My biggest concern today is the lack of motivation & boredom with what I'm working on.

Goals today

  • Write at least one passing test for Phad <- I've written NONE of the internals, so far.
  • Finish DocBlocking Liaison's classes. I'd love to get through the components today, too, but I don't think I'll be that fast.
  • Refine API Documentation Scraper in Code Scrawl. Not exactly sure what I want to accomplish here today, but it'd be nice to make some progress.

Getting started

  • Create a Status.md file for my cleanup branch of Git Bent & describe the purpose of the branch
  • Look up a thing about branch descriptions in git. Check twitter.
  • Create a Status.md for the 0.1-candidate branch of my PHP Testing lib & make some notes

Did a little on Phad. Took a breakfast break from roughly 10:52-11:50.

Phad Development

  • Setup my first test (figuring out what I'm testing & how to do it)
  • Need an str_contains assertion, so I updated my testing lib with slightly better architecture & this feature.
  • Doing work on internals & how to test
  • Took a fairly long break (bathroom, walk, make coffee)
  • This project is interesting, but I am REALLY not feeling it today.

Got some basic tests passing

<?php  
$Blog = (object)[  
    'body'=>'# Is police funding a form of welfare?',  
    'bodyTarget'=>'<h1>Is police funding a form of welfare?</h1>',  
];  
$view = <<<HTML  
    <section item="Blog">  
        <div prop="body" filter="commonmark:markdownToHtml"></div>  
    </section>  
HTML;  
$compiler = new \Phad\Compiler($view);  
$output = $compiler->output();  
$view = $output['view'];  
ob_start();  
eval('?>'.$view);  
$viewEvaled = ob_get_clean();  
  
$this->str_contains($viewEvaled, '<section>');  
$this->str_contains($viewEvaled, $Blog->bodyTarget);  

This inserts an object's properties into html & applies the given filter. This works.

Complications increase

Now I'm trying to add my custom node that should NOT output its tag (just the inner html)

<div>  
    <x-item item="Blog">  
        <h1 prop="title"></h1>  
        <p prop="description"></p>  
    </x-item>  
</div>  

So I inspect DOMDocument. Note, I'm using pHtml, so whatever features I need I can add in pHtml... which is good, because DOMDocument is freaking horrible.

pHtml

pHtml already has custom handling of output, so doing additional pre-processing shouldn't be an issue. So I'll add something like $node->tagHtmlIsHidden = true, that pHtml will scan for before calling saveHTML & do some fancy replacing.

Doing foreach ($domNode->childNodes) is a nightmare because childNodes is a DOMNodeList & foreaching just doesn't work (but i think it does sometimes? Idk). So I added a magic getter for $domNode->children that uses a for ($i...) loop to return an array from $domNode->childNodes.

Once this was done, it was a sinch to $xitem->removeChild($child); $xitem->parentNode->insertBefore($child,$xitem); in a loop, then $parentNode->removeChild($xitem).

Another passing test!

That block above (that contains x-item) is now successfully outputting:

<div>  
      
        <h1>The test title</h1>  
        <p>The test description</p>  
  
</div>  

yes... There is extra whitespace. So what.

Liaison Docs

This was a good day for PHAD (which REALLY needs a new name). I think I worked slowly, but I was pretty focused & got a decent amount done.
I also wanted to work on the docs today, so I'm gonna commit & switch over to that. & use cannabis, because I much prefer writing docs while high.

Alright, nearly an hour of doc writing in & its 6:06pm, so time for me to quit.

Conclusion

I'm glad I didn't stay in line with my goals. I planned only a couple hours work on Phad because its a tough project with lots of decisions to make & after a couple hours, I get decision fatigue & need to switch. But I stayed in a good headspace for it almost all day. After my last walk (about 4:50), I switched to Liaison docs, knowing that's just as important as Phad (if not more so). I'd still really like to work on Code Scrawl, but that needs updates to serve Liaison & Phad... So its not really a priority until I'm needing those features in Liaison & Phad. Mainly, tag & custom display features

It was a good day. I'm happy its my weekend now. I've liked writing devlogs this week. I think it helps keep me focused & on track. Plus it helps me stay accountable to myself, I think. I don't really expect anyone to read them, and that's okay (& maybe a little preferable sometimes).

In case you did read, hope you enjoyed!

Things I thought of today

  • I should write a little blog post about the error I got when doing foreach ($domNode->childNodes). Granted, I didn't search for the error. I usually don't have any look searching up DOMDocument errors. Plus I like looking at the docs & troubleshooting anyway. I feel like I learn more that way... though it does sometimes take longer.
  • I need a different code theme on my site. The StackOverflow theme doesn't mesh with my bright green/purple (& I <3 my green/purple)
  • Several other things, but I started Status.md documents for the relevant projects & put my thoughts in those.