-
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
mdBook forbids "empty chapters" since 0.1.0 #576
Comments
That's intended behaviour and was done in response to #566. The idea is that an empty link indicates you're linking to an invalid chapter. We can always swap it from an error to a warning so it acts like a lint, then continue on past the link. What are your thoughts?
I don't think links should be used for this purpose. It's probably a better idea to use separators |
I have a certain use case in mind. Unfortunately, I can't show the book because its internal documentation... But I can explain the idea: I have multiple locations with multiple machines and multiple services. Any machine and service got an FQDN as identifier. I have a book that acts as a reference for these FQDNs. The summary looks a bit like this:
Any FQDN has a documentation and is therefore a chapter in the book. But it makes no sense for me to have documentation pages for entries like "Location 1" or "Machines". Their single purpose is to improve the structure on the left side of the page. (You may say they are empty chapters which are skipped when using the arrow keys.) The second reasoning is: I really have a lot of FQDNs. Since I have not always used mdBook to render the documentation, not any FQDN is currently documented in mdBook -- I am still migrating. Those FQDNs have an entry in the summary but they are empty chapters that are skipped when moving through the documentation. Being forced to add a file for each of these "chapters" would simply bloat my repository at the current stage making it harder to track where work needs to be done. (Current approach is: No file available --> migration needed; file available --> migration complete or in progress)
I really like that idea. But the obvious drawback is, that these headers are not represented in the rendered book. They are stripped by mdBook and therefore not really helpful. |
I think, there are three ways to move on:
|
I think the previous behaviour was actually an unintended, albeit useful, bug in the HTML renderer. The internals of With that model in mind there isn't really any way to represent the idea of a "virtual" chapter, which then leads to issues of what to tie the sub-chapters to. I know the idea of a virtual chapter which only exists for namespacing purposes has been asked about in the past, so I'm going to look into updating the In the meantime, I imagine the easiest workaround for you will be to roll back to the |
That sounds great! Do you need help with the implementation? |
More help is always welcome 😁 The process isn't overly difficult, it just requires updating several parts which are in different places in the codebase. Namely the summary parser, the |
I'll have a try on this -- but not today... I think about adding a new variant Some advice? |
@Michael-F-Bryan I just finished my exams and am going through all the things I missed in the last months, so I am little out of the loop and late to the party 😉 Excellent work on everything by the way!
It was actually an intended feature. :) I don't remember exactly how it was implemented, but I am sure it was not pretty, hence the reason it was probably mistaken for a side-effect. |
That explains why The Rust Programming Language uses that behavior in the appendix.
That sounds reasonable. I would suggest that we first revert the patch that removes the feature. Then, in a second step, we could think about how to implement it in a way that it is not mistaken for a side effect. Maybe we could also add a passage in the user guide. Btw I've compared the current rendering result with TRPL. Seems that the line height in the summary is much higher now. Is that intended? |
I don't think its as easy as reverting a patch. This actually came about because we were restructuring internals to make things cleaner and formalize the I don't think we'd ever tested to make sure you can have an empty chapter for namespacing purposes, hence why it wasn't picked up until now. For reference, the current structure looks something like this: struct Book {
sections: Vec<BookItem>,
}
enum BookItem {
Separator,
Chapter(Chapter),
}
struct Chapter {
name: String,
path: PathBuf,
content: String,
sub_items: Vec<BookItem>,
} To do this properly, we'd need to add a As an aside, it looks like this is very similar to #483. |
Doing this is a breaking change no? |
I don't know, is it? Almost everyone uses the command line application and we should strive to prevent breaking changes when doing minor releases (although I screwed up by letting the configuration format change slip into @steveklabnik, what are you usually meant to do when the main project is a program, but that binary uses a backing crate? I know the |
yeah, it's a versioning issue with cargo, basically. that is, the version is per-package, not per-crate. that said, you're still pre-1.0, so this would be a "bump to 0.2" thing. no big deal. oh, we also use mdbook as a library to build rustc. it wouldn't be particularly onerous to update though. |
Yes I would bump the version whenever we do a breaking change, even if it is minor. :) |
I actually appreciate that you've bumped to version to I would also bump the version (major, minor, patch -- whatever is necessary) whenever a change happens to the binary or the library since the package represents both. Therefore, since this is a breaking change, the correct version would be
Exactly. |
Update to mdbook circa 1.5. Convert json to toml, surpress incomplete chapters (see: rust-lang/mdBook#576), and pull style sheet from latest theme.
@teiesti @azerupi @Michael-F-Bryan whats the current status of implementation for this? There has been lots of great progress with mdbook, but I can't use any of it since I rely on this feature. I would be willing to help with implementation if it would help. |
I've started to write a fix (#592) back in January but then got busy at university. @azerupi continued my work but I think he did not finish it. There has been no activity in the PR since March. I actually don't know what the current status is. I know that I still have no spare time to do this. Maybe you can take over from @azerupi? |
Ok, thanks for the update. I’ll try and take a look at what has been done. |
I'd also really need this feature. |
I would like to switch from gitbook with auto-generated SUMMARY.md with gitbook-summary wich creates a summary with "empty" chapters like: # Title
- EmptyChapter
* [Subchap](http://link)
* ...
- AnotherEmptyChap
* ... mdbook fails with that stucture because of EmptyChapter. |
+1 for this feature. Running on |
There is a PR open (#1153) that restores this behavior with the format of empty markdown links:
It is in review, just a little more patience 🙂 |
Closed via #1153. |
Until version 0.0.28, it was possible to have a
SUMMARY.md
like this:While the "real chapter" was rendered and given a link in the summary on the left-hand side, the "empty chapter" was just given an entry in the summary without a link.
This behaviour was very helpful in lots of cases, e.g.
Since version 0.1.0, empty chapters are not longer supported. They result in the following error:
Is the new behaviour intended? If yes, is it possible to revert that decision since the old behaviour has practical benefits?
The text was updated successfully, but these errors were encountered: