-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Book representation - Attempt 3 #491
Book representation - Attempt 3 #491
Conversation
@budziq this still has a fair amount of work to do to clean everything up and iron out the bugs, but it's starting to look the way I'd like. It was easier to start over than to try and solve several months worth of merge conflicts. All tests currently pass, plus the I'll try to fix the issue, although the root cause is that our HTML renderer is intimately coupled to the internals of |
34a698a
to
573c959
Compare
573c959
to
f36e4b9
Compare
@budziq and @steveklabnik, this PR has implemented most of the stuff it needs to so how should I go about the whole review process? It's a pretty large set of changes so it's probably not a good idea for me to merge this without getting someone else to have a skim through. But at the same time I'm quite conscious of the fact that you guys are quite busy and probably won't have time to do the review yourselves. Can you think of anyone else who's familiar with the internals of |
- You now use a `BookBuilder` for creating a book directory tree - This also removes the `--no-create` argument
I've finally had time to sit down and work on this PR and so far I'm pretty happy with how it's turned out. Something to note is one of the "breaking changes" I mentioned.
@cspiegel, you recently did some work to move the Also, @steveklabnik and @budziq, do you guys find this feature being used a lot in The Book and The Rust Cookbook, respectively? |
102060d
to
9950f69
Compare
Indeed, I like this feature because it makes for a smoother workflow. I know for a fact that it made at least one other person happy, because he mentioned it on twitter 😋 In my opinion, it would be a pity to see it go away. |
That's a good enough reason for me :) I'll see if I can implement it in a cleaner way than before, that was the big factor making me question whether to keep it. |
Aaaannnddd it's back (ace0b51). This time round I implemented it as a pass done after reading the summary but before we load the actual book. Previously we had to thread |
Looks like it's already been decided to keep it, but just for reference, I have no qualms about it being pulled out wholesale, if that's the direction things ultimately go. |
d34dc84
to
a46e2e2
Compare
I think I'm going to merge this soon. There are a couple places which may need some more work, but the overall design is pretty solid (decoupling This is more meant as a refactoring of the current system and underlying infrastructure to make it less coupled and easier to maintain. I've added a lot of tests, in particular using the Now that the internal representation of a cc: @frewsxcv, @budziq, @steveklabnik - I'm not sure if any of you guys will have time to do a full review, but it'd be nice to hear your thoughts. Skimming this issue's description and checking out a couple of the integration tests or |
I took a quick look and it looks good. I did not read everything, but I liked what I saw. Great job! 🎉 |
Cheers! I've started working on an alternate backend and found the new |
…tion-3 WIP: Book representation - Attempt 3
Due to excessive bitrot, I've decided to start #409 over again on top of
master
instead of trying to do a really complicatedgit rebase
and most probably accidentally clobbering a bunch of changes made since the branch was created. I made sure to steal all the good bits from that PR though!This PR makes a lot of breaking changes!
Due to how central our book's internal representation is to the library, I've ended up touching a lot more stuff than I'd like and was forced to do a lot of drive-by refactoring 😞
Changes introduced in this PR:
SUMMARY.md
parser to use thepulldown_cmark
crate instead of a custom Markdown parserBook
(internal representation of a book and its contents) and theBookItem
so that it's effectively a list ofBookItem
s, where the numbered sections can also contain a bunch ofBookItem
s.MDBook::init()
so that instead of being a method which will initialise theMDBook
, it returns aBookBuilder
which you can use to customise how the book and its directory structure will be createdMDBook::new()
constructor and replaced it with a (fallible)MDBook::load()
constructor which will immediately try to load the book from the provided source directoryMDBook
in a valid state. Previously you could load theMDBook
in an indeterminate state and would then have to manually callinit()
orparse_config()
to make sure things are okay. That still didn't ensure theSUMMARY.md
file insrc/
was valid (or even exists!) and that we could load the book.build()
on theBookBuilder
will generate all the files on disk, then immediately load the book and give you aMDBook
Removes thecreate_missing
feature which will automatically create any files fromSUMMARY.md
which don't existAlthough super convenient, this complicates the book parsing process and adds unexpected side-effects (loading a book should only read things from the filesystem)It's also pretty magical (who would have thought that reading theBook
from disk would also generate a bunch of files?)@azerupi was a big fan of this feature, so I'd like to hear his thoughts on removing this.Almost all of the above changes are backwards incompatible and will require a new minor release.