rangle / ngCourse2

An Angular Course from Rangle.io
Other
184 stars 126 forks source link

Cleaning Dead Markdown Pages #894

Closed adrianmcli closed 7 years ago

adrianmcli commented 7 years ago

Fixes #852

Please read the issue for context.

Intro

I have written a script to:

1) Check all links in SUMMARY.md to make sure all those linked Markdown files exist. 2) Check all Markdown files in the handout/ directory and see which of those are not being linked from SUMMARY.md.

The script resides in a new directory called $REPO_ROOT/utils/.

Results

This is the output from my script:

➜  ngCourse2 git:(feat-clean-dead-pages) ✗ node ./utils/checkMDFiles.js
----------------------------
Checking links in SUMMARY.md
----------------------------
Checked 254 file paths
All linked Markdown files exist

--------------------------------------------
Checking Markdown files in handout directory
--------------------------------------------
Found 270 Markdown files
Cannot find links in SUMMARY.md for 17 Markdown files:
Set {
  'handout/cli/tips-and-references.md',
  'handout/forms/async_validators.md',
  'handout/forms/built-in_validators.md',
  'handout/forms/control_grouping.md',
  'handout/forms/creating_a_form_with_directives.md',
  'handout/forms/creating_a_form_with_the_formbuilder.md',
  'handout/forms/custom_validators.md',
  'handout/forms/getting_the_forms_values.md',
  'handout/forms/models.md',
  'handout/forms/observing_changes.md',
  'handout/forms/validation.md',
  'handout/forms/visual_cues_with_css.md',
  'handout/testing/services/async.md',
  'handout/universal/README.md',
  'handout/universal/capturing_events_using_preboot.md',
  'handout/universal/setting_up_the_server.md',
  'handout/universal/universal_components.md' }

The numbers don't match exactly (254 + 17 = 271) because there is one file ./intro.md in SUMMARY.md that resides outside of the handout/ directory, but the results are otherwise consistent.

Cleaning Dead Pages

By running the script with a --clean flag, it can automatically delete the 17 orphaned Markdown files for you. I have done exactly that, and just for the sake of posterity, here is the output from my script:

--------------------------------
Cleaning Orphaned Markdown Files
--------------------------------
Deleting orphaned Markdown files...

  Deleted: handout/cli/tips-and-references.md
  Deleted: handout/forms/async_validators.md
  Deleted: handout/forms/built-in_validators.md
  Deleted: handout/forms/control_grouping.md
  Deleted: handout/forms/creating_a_form_with_directives.md
  Deleted: handout/forms/creating_a_form_with_the_formbuilder.md
  Deleted: handout/forms/custom_validators.md
  Deleted: handout/forms/getting_the_forms_values.md
  Deleted: handout/forms/models.md
  Deleted: handout/forms/observing_changes.md
  Deleted: handout/forms/validation.md
  Deleted: handout/forms/visual_cues_with_css.md
  Deleted: handout/testing/services/async.md
  Deleted: handout/universal/README.md
  Deleted: handout/universal/capturing_events_using_preboot.md
  Deleted: handout/universal/setting_up_the_server.md
  Deleted: handout/universal/universal_components.md

17 Markdown files deleted

Going Forward

I have gone through the book to make sure that these 17 pages are not necessary, but it would probably be a good idea to have someone double check that.

Another consideration is whether or not we want to keep the script I wrote at all. I think it is a useful utility to keep the repo clean going forward, but I also understand if some may consider it to be clutter.

If we do decide to keep the script, it might be a good idea to also insert an NPM script so you could call it easily.

If all else is fine, this PR should be ready for merging.