Skip to content

Conversation

@eah13
Copy link
Contributor

@eah13 eah13 commented Feb 16, 2017

This PR adds several trinkets to the text and our basic publisher tools script.

I modified the trinket environment to accept a mandatory argument that is the filename. This is currently printed at the top of all trinkets, which causes a syntax error for now. An upcoming modification to our parser will automatically rename the main file to be this argument value. For now, comment or delete that first line and manually rename the file to test. These examples will magically start working when this update gets pushed.

The best way to test is to clone and make -i trinket. Here's on of the chapters running from a dev server (crtl-f for 1.4 to find the first trinket:

https://silshack-eah13.c9.io/trinkethtml/thinkjava6002.html

I did a quick search for public class and added trinkets where they looked complete. To support multi-class programs, I believe we'll need to implement some sort of file reading capacity to the environment so when students are extending classes we can include those files in the trinkets that need them. Something like this:

\begin{trinket}{Player.java}[/code/Deck.java, /code/CardCollection.java, /code/Card.java]
public class Player {

    private String name;
    private Hand hand;

    public Player(String name) {
        this.name = name;
        this.hand = new Hand(name);
    }
\end{trinket}

That'll require adding these java files into the repo somewhere. If they're already in another repo we could do a subtree or assume that that repo exists as a sibling to this one for trinket builds (or etc). There will be complexity if there are multiple files called e.g. Card.java but we can cross that bridge when we get there.

Aside: in the PDF and other non-html builds, the Filename argument in the Trinket environment could be used to label the code examples in the book with their filenames. That would let students map the example to the code files included with the book, making that part of reading it easier.

Some other PR notes:

  • I had to make the trinket make task Phony so it'd run every time for debugging purposes
  • I .gitignored /html and /trinkethtml since we probably don't want to be committing build results. That can obviously be undone but seems best practice.
  • Worth a doublecheck to make sure these changes don't mess up any other builds. They shouldn't but I'll be happy to fix any regressions. Figure this is a job for @committers since you gents know what the builds should look like.
  • some of the images etc are broken but I'm not sweating that since we'll do an overhaul of image handling and restyle the book as we go.

@eah13
Copy link
Contributor Author

eah13 commented Feb 20, 2017

@AllenDowney @ChrisMayfield filename parsing is now working! https://silshack-eah13.c9.io/trinkethtml/thinkjava6002.html#sec11

The trinkets in this PR should all now run & load, no changes to the code needed. I do owe you a small Makefile update. incoming...

@ChrisMayfield
Copy link
Collaborator

Thank you for this work! I like the idea of including filenames for examples in the PDF build. We have a separate repo for code (https://github.com/AllenDowney/ThinkJavaCode), but we might merge them in a future edition (like https://github.com/AllenDowney/ThinkDataStructures does).

@ChrisMayfield ChrisMayfield merged commit 802057b into AllenDowney:master Feb 21, 2017
@eah13 eah13 deleted the trinket-poc branch February 21, 2017 21:49
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.

2 participants