Urigo / tortilla

The Framework for tutorials
MIT License
51 stars 5 forks source link

Table of Contents #214

Closed leonardoventurini closed 4 years ago

leonardoventurini commented 4 years ago

Description

I implemented a handlebars helper to render a basic Table of Contents based on git log by using the following directive in the template files:

{{{ toc }}}

For now, the anchors follow GitHub's markdown algorithm I guess, but it is easy to implement more templating options.

Generated Markdown Example

image

image

leonardoventurini commented 4 years ago

The substeps are linking to manually added subheaders... I will need to find a better way to do this. Currently, I can use my changes but other people might have a hard time using them.

So I will close the pull request and create a new pull request later on. Thanks.

Urigo commented 4 years ago

thank you for the update @leonardoventurini

Urigo commented 4 years ago

Looking forward to get this done. If you need help, don't hesitate to ask!

leonardoventurini commented 4 years ago

Looking forward to get this done. If you need help, don't hesitate to ask!

Sure, I had some problems when running the tortilla manual render --all since it is recursive and the following iterations are all from within rebase, I probably need to store in the log in localStorage or something I guess... thanks @Urigo

leonardoventurini commented 4 years ago

The recursion problem is fixed. :tada: @Urigo

DAB0mB commented 4 years ago

I have added few comments. Also I cannot merge it without tests, if you have any questions about that free feel to ask.

leonardoventurini commented 4 years ago

I have added few comments. Also I cannot merge it without tests, if you have any questions about that free feel to ask.

@DAB0mB Oh, right, I forgot about the tests. I will be on that next then.

leonardoventurini commented 4 years ago

I have added few comments. Also I cannot merge it without tests, if you have any questions about that free feel to ask.

@DAB0mB There are three tests failing on master... I will see what I can do about those, but I guess I do not have much time available... but I guess you would want to check the tests... unless they are known to be failing that is.

DAB0mB commented 4 years ago

@leonardoventurini If they are failing on master I will fix them, but if in the meantime you can write tests to your features that would be good. It's possible that the git version is causing the tests to fail.

leonardoventurini commented 4 years ago

Hello @DAB0mB, I have added a test with a simple data mock for the handlebars helper. Simple stuff... how likely would it be for me to get some help setting up more complex tests? I just cannot wrap my head around the testing environment without some docs... and I am quite short on time lately. It would help me a lot if you guys took on this small feature from here onwards, less chance I might break something. Thanks.

DAB0mB commented 4 years ago

@leonardoventurini There should be numerous examples in the test files. Here's one of them. You see the difference? You actually created a fake log, and you edited the local storage. That's not a good way to test things, because you don't emulate a real scenario. In practicality, what you should do is running real git and tortilla via child process utilities and render a Tortilla manual like you normally would. So it should (roughly) go like this:

tortilla step edit --root
bach -c 'echo "{{{ table }}}" > .tortilla/templates/root.tml'
tortilla step push -m "test step 1.1"
tortilla step push -m "test step 1.2"
tortilla step tag -m "test step 2"
tortilla step push -m "test step 2.1"
git rebase --continue
tortilla manual render --all

Let me know how things go.

leonardoventurini commented 4 years ago

@DAB0mB I had something crazy in mind, saw all those files and thought I had to do something else entirely, turns out it is easier than I thought, I got something working, but I will add some things more until this weekend. thanks a lot.

leonardoventurini commented 4 years ago

@DAB0mB done, I added one more test to take into account the possibility of rendering the table of contents anywhere and removed the file... anything else I should do? there will be more pull requests in the future as our use case for the table of contents mature. next, I plan on finding a way to generate the subheaders for the substeps, since the table of contents has to point somewhere, and writing those by hand might not be ideal.