check if README.md exists before attempting to read it #490
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
This PR addresses #432, a bug where esdoc fails to run if a
README.md
file is not present at the root of a given project. The bug occurs because the default behaviour of esdoc is to attempt to read that file regardless of whether or not it exists.Solution
The simple solution here is to check if the file exists before attempting to read from it, and fall back to empty string as the index content if the file does not exist.
Further thoughts
On the issue there are reports of esdoc also crashing if a readme is present at the top level of the project but its not named exactly
README.md
, which may frequently be the case on case sensitive file systems. This PR does not remedy that scenario by reading the correct file but it will at least allow esdoc to run without crashing. It is up to the user then to find the correct configuration option from theESDoc Config
table here: https://github.com/esdoc/esdoc-site/blob/master/src/manual/config.mdOutcome
Resolves #432 and duplicate #484.