chirun-ncl / chirun

A Python package providing the command line interface for building flexible and accessible content with Chirun.
https://chirun.org.uk/
Other
29 stars 4 forks source link

makecourse has stopped re-making the site index page #102

Closed prowlett closed 2 years ago

prowlett commented 2 years ago

Starting a new dummy course with config.yml like this:

title: "Test course"
code: 55-xxxxxx
year: 2021/22
base_dir: blank-course
author: Peter Rowlett
structure:
    - type: introduction
      source: intro.tex
      leading_text: "Welcome."
    - type: part
      title: Just a basic page
      content:
        - type: chapter
          title: Test page
          source: test-folder/test-file.tex
themes:
  - title: Default
    source: default
    path: default
build_pdf: True

I run makecourse and get an build/default/index.html file like this:

Screenshot from 2021-09-20 15:16:10

I then create a new file (definitely then, i.e. the file is created after running makecourse) and edit the config.yml to look like this:

title: "Test course"
code: 55-xxxxxx
year: 2021/22
base_dir: blank-course
author: Peter Rowlett
structure:
    - type: introduction
      source: intro.tex
      leading_text: "Welcome."
    - type: part
      title: Just a basic page
      content:
        - type: chapter
          title: Test page
          source: test-folder/test-file.tex
        - type: chapter
          title: Test page
          source: test-folder/second-test-file.tex
themes:
  - title: Default
    source: default
    path: default
build_pdf: True

Then I run makecourse again, but the index.html file does not change.

It does something, because second-test-file.aux, second-test-file.fls and second-test-file.log are created and new files build/default/just_a_basic_page/test_page_1/index.html and build/default/just_a_basic_page/test_page_1/test_page_1.pdf are created. It's just that it doesn't recreate build/default/index.html.

If I delete build/default/index.html and re-run makecourse, all is well and my site now looks like this:

Screenshot from 2021-09-20 15:21:31

Oh, I just ran through this again and noticed it is only apparently build/default/index.html that is affected - after I have added a new file and re-run makecourse, the file build/default/just_a_basic_page/index.html is updated with a link to the new file.

If I comment out the new file from config.yml it instantly vanishes from build/default/just_a_basic_page/index.html but is still there on build/default/index.html. Only when I delete build/default/index.html and re-run does it produce the correct menu.

prowlett commented 2 years ago

I'm using 94b65b1.

prowlett commented 2 years ago

Just to update, I've done a --force-reinstall upgrade to bddc636 and the problem is still happening.

prowlett commented 2 years ago

My fix at the moment is to manually delete build/default/index.html before each time I run makecourse.

prowlett commented 2 years ago

Just to note this is still happening with 6a782cc. I'm continuing to manually delete build/default/index.html before each time I run makecourse.

georgestagg commented 2 years ago

Commit 2629071 should hopefully help. introduction and part pages will rebuild whenever config.yml is newer than the output.

prowlett commented 2 years ago

I think that's made it worse.

I did pip install --upgrade git+https://github.com/coursebuilder-ncl/makecourse.git --force-reinstall.

Then I made a new course in to-break/ with three files:

config.yml:

title: "Test course"
code: 55-xxxxxx
year: 2021/22
base_dir: test-course
author: Peter Rowlett
structure: 
    - type: introduction
      source: intro.tex
      leading_text: "Welcome to the module notes."
    - type: part
      title: Test part
      content:
        - type: chapter
          title: Something
          source: something.md
themes: 
  - title: Default
    source: default
    path: default
build_pdf: True

intro.tex:

\documentclass{article}
\begin{document}
Hello.
\end{document}

something.md:

# Something

Hello.

Then I ran makrcourse -vv and the output was this:

Running makecourse for directory /home/.../to-break
makeCourse:load_config:153: DEBUG:  Reading config file config.yml
makeCourse:find_theme:187: DEBUG:   Finding theme default
makeCourse:find_theme:190: DEBUG:   Trying themes/default
makeCourse:find_theme:190: DEBUG:   Trying /home/.../coursebuilder_env/bin/themes/default
makeCourse:find_theme:190: DEBUG:   Trying /home/.../coursebuilder_env/lib/python3.9/site-packages/makeCourse/themes/default
makeCourse:build_with_theme:317: DEBUG: 
The static directory is: static
The build directory is: build/default
The web root directory is: /home/.../to-break/build/default/

makeCourse:make_directories:292: DEBUG: Creating build directory...
makeCourse.theme:copy_static_files:43: DEBUG:   Copying theme's static directory to the build's static directory...
makeCourse.theme:copy_static_files:44: DEBUG:       /home/.../coursebuilder_env/lib/python3.9/site-packages/makeCourse/themes/default/static => build/default/static
makeCourse:copy_static_files:211: DEBUG:    Copying course's static directory to the build's static directory...
makeCourse:load_structure:226: DEBUG:   Loading course structure
makeCourse:process:234: DEBUG:  Starting processing
makeCourse:process:238: INFO:   Process: Checking for duplicated filenames or paths
makeCourse.process:visit:51: DEBUG: Checking slug: index
makeCourse.process:visit:51: DEBUG: Checking slug: test_part
makeCourse.process:visit:51: DEBUG: Checking slug: something
makeCourse:process:238: INFO:   Process: Establish when each item was last built
makeCourse:process:238: INFO:   Process: Make PDFs
makeCourse.render:render_item:63: INFO: Rendering: something.md
makeCourse.render:render_item:64: DEBUG:    Rendering chapter "Something" using chapter.html using relative paths.
makeCourse.render:to_pdf:85: INFO:  Printing chapter "Something" to PDF
makeCourse.render:to_pdf:88: DEBUG:     Something => build/default/test_part/something/something.pdf
makeCourse:process:238: INFO:   Process: Render items to HTML
makeCourse:process:241: INFO:   Run 1/2
makeCourse.render:render_item:63: INFO: Rendering: intro.tex
makeCourse.render:render_item:64: DEBUG:    Rendering introduction using index.html using relative paths.
DEBUG: PlasTeX: intro.tex
 ( /home/.../coursebuilder_env/lib/python3.9/site-
   packages/plasTeX/Packages/article.py
 )
INFO: Importing templates from
   /home/.../coursebuilder_env/lib/python3.9/site-
   packages/plasTeX/Renderers/PageTemplate
INFO: Importing templates from
   /home/.../coursebuilder_env/lib/python3.9/site-
   packages/makeCourse/plasTeXRenderer
INFO: Importing templates from
   /home/.../coursebuilder_env/lib/python3.9/site-
   packages/makeCourse/plasTeXRenderer/Themes/default
 [ index.html ]makeCourse.render:render_item:64: DEBUG: Rendering part "Test part" using part.html using relative paths.
makeCourse.render:render_item:63: INFO: Rendering: something.md
makeCourse.render:render_item:64: DEBUG:    Rendering chapter "Something" using chapter.html using relative paths.
makeCourse:process:241: INFO:   Run 2/2
makeCourse.render:render_item:63: INFO: Rendering: intro.tex
makeCourse.render:render_item:64: DEBUG:    Rendering introduction using index.html using relative paths.

DEBUG: PlasTeX: intro.tex
 ( /home/.../coursebuilder_env/lib/python3.9/site-
   packages/plasTeX/Packages/article.py
 )
INFO: Importing templates from
   /home/.../coursebuilder_env/lib/python3.9/site-
   packages/plasTeX/Renderers/PageTemplate
INFO: Importing templates from
   /home/.../coursebuilder_env/lib/python3.9/site-
   packages/makeCourse/plasTeXRenderer
INFO: Importing templates from
   /home/.../coursebuilder_env/lib/python3.9/site-
   packages/makeCourse/plasTeXRenderer/Themes/default
 [ index.html ]makeCourse.render:render_item:64: DEBUG: Rendering part "Test part" using part.html using relative paths.
makeCourse.render:render_item:63: INFO: Rendering: something.md
makeCourse.render:render_item:64: DEBUG:    Rendering chapter "Something" using chapter.html using relative paths.
makeCourse:process:245: DEBUG:  Done processing!
makeCourse:cleanup:267: INFO:   Cleaning up temporary files
All done! Output written to /home/.../to-break/build

This creates three webpages:

build/default/index.html:

Screenshot from 2021-09-22 18:16:13

build/default/test_part/index.html:

Screenshot from 2021-09-22 18:16:24

build/default/test_part/something/index.html:

Screenshot from 2021-09-22 18:16:31

Now I create other-thing.md:

# Other thing

Hello too. 

Then I edited config.yml to this:

title: "Test course"
code: 55-xxxxxx
year: 2021/22
base_dir: test-course
author: Peter Rowlett
structure:
    - type: introduction
      source: intro.tex
      leading_text: "Welcome to the module notes."
    - type: part
      title: Test part
      content:
        - type: chapter
          title: Something
          source: something.md
        - type: chapter
          title: Other
          source: other-thing.md
themes:
  - title: Default
    source: default
    path: default
build_pdf: True

I ran makecourse -vv again and the output is:

Running makecourse for directory /home/.../to-break
makeCourse:load_config:153: DEBUG:  Reading config file config.yml
makeCourse:find_theme:187: DEBUG:   Finding theme default
makeCourse:find_theme:190: DEBUG:   Trying themes/default
makeCourse:find_theme:190: DEBUG:   Trying /home/.../coursebuilder_env/bin/themes/default
makeCourse:find_theme:190: DEBUG:   Trying /home/.../coursebuilder_env/lib/python3.9/site-packages/makeCourse/themes/default
makeCourse:build_with_theme:317: DEBUG: 
The static directory is: static
The build directory is: build/default
The web root directory is: /home/.../to-break/build/default/

makeCourse:make_directories:292: DEBUG: Creating build directory...
makeCourse.theme:copy_static_files:43: DEBUG:   Copying theme's static directory to the build's static directory...
makeCourse.theme:copy_static_files:44: DEBUG:       /home/.../coursebuilder_env/lib/python3.9/site-packages/makeCourse/themes/default/static => build/default/static
makeCourse:copy_static_files:211: DEBUG:    Copying course's static directory to the build's static directory...
makeCourse:load_structure:226: DEBUG:   Loading course structure
makeCourse:process:234: DEBUG:  Starting processing
makeCourse:process:238: INFO:   Process: Checking for duplicated filenames or paths
makeCourse.process:visit:51: DEBUG: Checking slug: index
makeCourse.process:visit:51: DEBUG: Checking slug: test_part
makeCourse.process:visit:51: DEBUG: Checking slug: something
makeCourse:process:238: INFO:   Process: Establish when each item was last built
makeCourse:process:238: INFO:   Process: Make PDFs
makeCourse:process:238: INFO:   Process: Render items to HTML
makeCourse:process:241: INFO:   Run 1/2
makeCourse.render:render_item:64: DEBUG:    Rendering part "Test part" using part.html using relative paths.
makeCourse:process:241: INFO:   Run 2/2
makeCourse.render:render_item:64: DEBUG:    Rendering part "Test part" using part.html using relative paths.
makeCourse:process:245: DEBUG:  Done processing!
makeCourse:cleanup:267: INFO:   Cleaning up temporary files
All done! Output written to /home/.../to-break/build

Now none of the pages in build/default/ have changed visually. The file modified time on build/MANIFEST.yml and build/default/test_part/index.html have updated to now, but the file modified time on build/default/index.html is still five minutes ago.

This is worse, because prior to commit 2629071 what would happen is that build/default/other/ and its contents would be created, these would be placed into the menu on build/default/test_part/index.html, but the problem is that the new file would not be reflected in build/default/index.html.

prowlett commented 2 years ago

Argh, no, sorry - I just found config.yml unsaved. I saved it and ran it and I think it worked now but my tea is ready so I will check properly later...

prowlett commented 2 years ago

Right, I have now run through this again, making a third file and properly adding it to config.yml and can confirm that it has made the new HTML file and re-made build/default/index.html and build/default/test_part/index.html to include the new item.

Thanks!