Giter Site home page Giter Site logo

themes's People

Contributors

aaranxu avatar actions-user avatar bennetthardwick avatar codeandmedia avatar daudix avatar emilioziniades avatar gamingrobot avatar gicrisf avatar hugo-trentesaux avatar jieiku avatar keats avatar kuznetsov17 avatar kyoheiu avatar mattyrad avatar netoun avatar not-matthias avatar pawroman avatar pixadus avatar ratanshreshtha avatar schoenenberg avatar semanticdata avatar sirodoht avatar ssiyad avatar st1020 avatar svavs avatar syedzayyan avatar tchartron avatar teadrinkingprogrammer avatar welpo avatar zbrox avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

themes's Issues

theme update action didn't trigger PR action

I see the "update all themes" action ran successfully this morning. However it didn't trigger the other action that creates the PR to the main zola repo.

Digging around, I came across this answer:
https://github.com/orgs/community/discussions/27598#discussioncomment-3279511

If you want the push from an action to trigger another action, you need to create a PAT and use that to authorize the push

Not sure if you want to setup a PAT to be used in the action? If you do, then it would be pretty straightforward to update the action. I'll gladly make the PR.

name: Update all themes

on:
  workflow_dispatch:
  schedule:
    - cron: "51 5 * * 1"

jobs:
  update-all-themes:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          submodules: "recursive"
+         token: ${{ secrets.GH_PAT }}
      - name: Update submodules
        run: "git submodule update --remote"
      - name: Commit and push changes
        run: |
          git status
          if [[ `git status --short` ]]; then
            git config --local user.email "[email protected]"
            git config --local user.name "GitHub Action"
            git commit -am "Update all themes"
            git push
          fi

Handling errors in theme parsing without halting entire process

TL;DR

The generate_docs.py script halts when a theme's TOML is malformed, preventing further processing of other themes. Proposing to capture and log these errors instead of stopping the entire process, and then display a summary at the end.

Description

While using the generate_docs.py script, the process halts entirely when encountering a theme with a malformed TOML, such as duplicate keys. This is currently happening with the zola-henry theme: sirodoht/zola-henry#6

Problem

If a theme's TOML has a duplicate key or any other TOML error, the script halts entirely. This means that a single theme with a malformed TOML can stop all subsequent themes from being processed.

While the current behavior makes it evident which theme has an error due to the halt, this approach may not be ideal if the goal is to update/process all themes that have no errors.

Proposed solution

  1. Instead of halting the entire script upon encountering an error, capture the error and continue processing the next theme.
  2. Append the error to a list or log.
  3. At the conclusion of the script's run, display a summary of all themes that had errors.

Advantages

  • Ensures that one malformed theme doesn't prevent other themes from being processed.
  • Provides a clear summary of themes with errors, presented at the end for easy reference.

Sample code changes

# Global scope
errors = []

# Inside Theme class constructor
try:
    with open(os.path.join(self.path, "theme.toml")) as f:
        self.metadata = toml.load(f)
except Exception as e:
    error_message = f"Error parsing TOML for theme {self.name}. {str(e)}"
    errors.append(error_message)
    self.metadata = None
    return

# At the end of the script
if errors:
    print("\n\n---- ERRORS ----")
    for error in errors:
        print(error)

It might also be a good idea to add a summary line at the end of the script that tells how many themes were successfully processed and how many had errors:

print(f"Processed {successful_count} themes successfully. Encountered errors in {error_count} themes.")

I'd be happy to create a PR with the suggested changes.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.