Skip to content

Tut-powered blog #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 9, 2016
Merged

Tut-powered blog #119

merged 9 commits into from
Oct 9, 2016

Conversation

larsrh
Copy link
Contributor

@larsrh larsrh commented Oct 3, 2016

Usage

  1. Put a blog post into posts instead of _posts.

  2. Add the following front matter:

    tut:
      scala: 2.11.8
      binaryScala: "2.11"
      dependencies:
        - org.typelevel::cats-core:0.7.2
    
  3. sbt run

  4. This will process the posts/*.md files into _posts.

Todo

  • unyolo error handling
  • make Travis execute sbt run
  • make Travis check that there are no dirty files
  • ... or let Travis deploy it in the first place?

@larsrh
Copy link
Contributor Author

larsrh commented Oct 3, 2016

Review by @tpolecat who should prepare himself with his bucket first. I have a suspicion that my code is too sloppy for him.

@adelbertc
Copy link
Contributor

Hm is there a reason why you removed the book modifier?

@larsrh
Copy link
Contributor Author

larsrh commented Oct 3, 2016

Did I? I have no idea what that modifier does.

On 3 October 2016 20:46:38 CEST, Adelbert Chang notifications@github.com wrote:

Hm is there a reason why you removed the book modifier?

You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub:
#119 (comment)

@adelbertc
Copy link
Contributor

adelbertc commented Oct 3, 2016

Oh right because you only have the compiled file. I'll PR against your branch the original tut file I have.

EDIT Here you go: https://github.com/larsrh/typelevel.github.com/pull/1

@tpolecat
Copy link
Member

tpolecat commented Oct 3, 2016

This looks good to me. I wonder if it should just be folded into tut. It's a distinct use-case but not uncommon, it turns out. Maybe see how it works out here first.

As an optimization I think you can safely do up-to-date checks on output files since your dependencies are all binaries.

@larsrh
Copy link
Contributor Author

larsrh commented Oct 4, 2016

This looks good to me. I wonder if it should just be folded into tut. It's a distinct use-case but not uncommon, it turns out.

There are two possible approaches for folding it into tut:

  • Don't use coursier to download an appropriate tut version, just use depend on tut-core directly. Advantage: Less classloading magic. Disadvantage: You'd need to support all sorts of Scala versions into eternity.
  • Use coursier to download an appropriate tut version. Advantage: Easier cross-Scala support over time. Disadvantage (?): Code inside tut which doesn't depend on anything else in there.

Maybe see how it works out here first.

Sounds like a good idea.

As an optimization I think you can safely do up-to-date checks on output files since your dependencies are all binaries.

Could you explain that? I don't understand what that means.

// match expected type cats.Functor[F]
// def callBar[F[_]: Monad: Traverse]: F[Int] = bar[F]
// ^
scala> def callBar[F[_]: Monad: Traverse]: F[Int] = bar[F]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we expect the compiled (from tut) code to be part of commits? For instance the tut file changed after https://github.com/larsrh/typelevel.github.com/pull/1 but the corresponding post does not reflect that (there should be no difference between what's currently in master and what is generated from the tut I PR'd).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that's the expectation in the current setup.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I wonder if it's possible to do this through CI. Not sure how that would work though since the file would be created as part of the CI process and then somehow added to the commit.

On a related note, this file needs to be re-generated then since it's not the same if you generate from what the tut file is now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One possibility is to:

  1. move all posts to the _tut directory
  2. add _posts to .gitignore
  3. copy non-tut files from _tut to _posts
  4. process tut files from _tut to _posts
  5. let Travis commit the results in the gh-pages branch

@tpolecat
Copy link
Member

tpolecat commented Oct 5, 2016

As an optimization I think you can safely do up-to-date checks on output files since your dependencies are all binaries.

Could you explain that? I don't understand what that means.

What I mean is, if the output file exists and is newer than the source file, there's no point running tut. Might be worth it to check since running tut this way is expensive.

(Normally tut can't do this because the tut documents depend on project sources that may have changed even if the tut input doc didn't.)

@larsrh
Copy link
Contributor Author

larsrh commented Oct 5, 2016

Got it.

@larsrh larsrh changed the base branch from master to development October 9, 2016 19:11
@larsrh
Copy link
Contributor Author

larsrh commented Oct 9, 2016

@tpolecat I've implemented your optimization. I'm now implementing automatic deployment.

@larsrh larsrh merged commit 2e65a03 into typelevel:development Oct 9, 2016
@larsrh larsrh mentioned this pull request Oct 9, 2016
@larsrh larsrh deleted the topic/tut branch October 9, 2016 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants