Customizable Section Name
This commit is contained in:
		@@ -58,6 +58,7 @@
 | 
				
			|||||||
   INPUT_REPOSITORY='<REPOSITORY SLUG>'
 | 
					   INPUT_REPOSITORY='<REPOSITORY SLUG>'
 | 
				
			||||||
   INPUT_COMMIT_MESSAGE='<COMMIT MESSAGE>'
 | 
					   INPUT_COMMIT_MESSAGE='<COMMIT MESSAGE>'
 | 
				
			||||||
   INPUT_SHOW_TITLE='True'
 | 
					   INPUT_SHOW_TITLE='True'
 | 
				
			||||||
 | 
					   INPUT_SECTION_NAME='wakacustom'
 | 
				
			||||||
   INPUT_BLOCKS='->'
 | 
					   INPUT_BLOCKS='->'
 | 
				
			||||||
   INPUT_SHOW_TIME='True'
 | 
					   INPUT_SHOW_TIME='True'
 | 
				
			||||||
   INPUT_SHOW_TOTAL='True'
 | 
					   INPUT_SHOW_TOTAL='True'
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -30,7 +30,7 @@ Alternatively, you can also fetch data from WakaTime compatible services like [W
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
A GitHub repository and a README file is required. We'll be making use of readme in the [profile repository][profile_readme]\*.
 | 
					A GitHub repository and a README file is required. We'll be making use of readme in the [profile repository][profile_readme]\*.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- Save the README file after copy-pasting the following special comments. Your dev-metics will show up in between.
 | 
					- Save the README file after copy-pasting the following special comments. Your dev-metics will show up in between. `waka` here can be replaced by any string as long as you set the `SECTION_NAME` environment variable [as per the Tweaks section](tweaks).
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    ```md
 | 
					    ```md
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -78,6 +78,7 @@ There are many flags that you can tweak to suit your taste!
 | 
				
			|||||||
| ------------------ | -------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
 | 
					| ------------------ | -------------------------------------------- | ---------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
 | 
				
			||||||
| `API_BASE_URL`     | `https://wakatime.com/api`                   | `https://wakatime.com/api`, `https://wakapi.dev/api`, `https://hakatime.mtx-dev.xyz/api` | Integration with WakaTime compatible services like [Wakapi][wakapi] & [Hakatime][hakatime] are possible |
 | 
					| `API_BASE_URL`     | `https://wakatime.com/api`                   | `https://wakatime.com/api`, `https://wakapi.dev/api`, `https://hakatime.mtx-dev.xyz/api` | Integration with WakaTime compatible services like [Wakapi][wakapi] & [Hakatime][hakatime] are possible |
 | 
				
			||||||
| `REPOSITORY`       | `<gh_username>/<gh_username>`                | `<gh_username>/<repo_name>`                                                              | Waka-readme stats will appear on the provided repository                                                |
 | 
					| `REPOSITORY`       | `<gh_username>/<gh_username>`                | `<gh_username>/<repo_name>`                                                              | Waka-readme stats will appear on the provided repository                                                |
 | 
				
			||||||
 | 
					| `SECTION_NAME`       | `waka`                | `any string`                                                              | The generator will look for this section to fill up the readme.                                                |
 | 
				
			||||||
| `COMMIT_MESSAGE`   | `Updated waka-readme graph with new metrics` | anything else!                                                                           | Messaged used when committing updated stats                                                             |
 | 
					| `COMMIT_MESSAGE`   | `Updated waka-readme graph with new metrics` | anything else!                                                                           | Messaged used when committing updated stats                                                             |
 | 
				
			||||||
| `SHOW_TITLE`       | `false`                                      | `false`, `true`                                                                          | Add title to waka-readme stats blob                                                                     |
 | 
					| `SHOW_TITLE`       | `false`                                      | `false`, `true`                                                                          | Add title to waka-readme stats blob                                                                     |
 | 
				
			||||||
| `BLOCKS`           | `░▒▓█`                                       | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, you can be creative!                                           | Ascii art used to build stats graph                                                                     |
 | 
					| `BLOCKS`           | `░▒▓█`                                       | `░▒▓█`, `⣀⣄⣤⣦⣶⣷⣿`, `-#`, you can be creative!                                           | Ascii art used to build stats graph                                                                     |
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -34,6 +34,11 @@ inputs:
 | 
				
			|||||||
    default: "false"
 | 
					    default: "false"
 | 
				
			||||||
    required: false
 | 
					    required: false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  SECTION_NAME:
 | 
				
			||||||
 | 
					    description: "Section name for data to appear in readme"
 | 
				
			||||||
 | 
					    required: false
 | 
				
			||||||
 | 
					    default: "waka"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  BLOCKS:
 | 
					  BLOCKS:
 | 
				
			||||||
    description: "Add the progress blocks of your choice"
 | 
					    description: "Add the progress blocks of your choice"
 | 
				
			||||||
    default: "░▒▓█"
 | 
					    default: "░▒▓█"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										15
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								main.py
									
									
									
									
									
								
							@@ -66,10 +66,16 @@ class WakaConstants:
 | 
				
			|||||||
    """
 | 
					    """
 | 
				
			||||||
    prefix_length: int = 16
 | 
					    prefix_length: int = 16
 | 
				
			||||||
    graph_length: int = 25
 | 
					    graph_length: int = 25
 | 
				
			||||||
    start_comment: str = '<!--START_SECTION:waka-->'
 | 
					    section: str = os.getenv("INPUT_SECTION_NAME", "waka")
 | 
				
			||||||
    end_comment: str = '<!--END_SECTION:waka-->'
 | 
					    start_comment: str = f'<!--START_SECTION:{section}-->'
 | 
				
			||||||
 | 
					    end_comment: str = f'<!--END_SECTION:{section}-->'
 | 
				
			||||||
    waka_block_pattern: str = f'{start_comment}[\\s\\S]+{end_comment}'
 | 
					    waka_block_pattern: str = f'{start_comment}[\\s\\S]+{end_comment}'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def validate_constants(self) -> bool:
 | 
				
			||||||
 | 
					        if not (self.section):
 | 
				
			||||||
 | 
					            logger.error('Invalid section name input, refer README')
 | 
				
			||||||
 | 
					            return False
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class WakaInput:
 | 
					class WakaInput:
 | 
				
			||||||
    """
 | 
					    """
 | 
				
			||||||
@@ -336,7 +342,7 @@ def churn(old_readme: str, /) -> str | None:
 | 
				
			|||||||
    if not (waka_stats := fetch_stats()):
 | 
					    if not (waka_stats := fetch_stats()):
 | 
				
			||||||
        logger.error('Unable to fetch data, please rerun workflow')
 | 
					        logger.error('Unable to fetch data, please rerun workflow')
 | 
				
			||||||
        sys.exit(1)
 | 
					        sys.exit(1)
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
    # processing content
 | 
					    # processing content
 | 
				
			||||||
    generated_content = prep_content(waka_stats)
 | 
					    generated_content = prep_content(waka_stats)
 | 
				
			||||||
    print(generated_content, '\n', sep='')
 | 
					    print(generated_content, '\n', sep='')
 | 
				
			||||||
@@ -350,6 +356,7 @@ def churn(old_readme: str, /) -> str | None:
 | 
				
			|||||||
        # to avoid accidentally writing back to Github
 | 
					        # to avoid accidentally writing back to Github
 | 
				
			||||||
        # when developing and testing WakaReadme
 | 
					        # when developing and testing WakaReadme
 | 
				
			||||||
        return None
 | 
					        return None
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
    return None if new_readme == old_readme else new_readme
 | 
					    return None if new_readme == old_readme else new_readme
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -411,7 +418,7 @@ if __name__ == '__main__':
 | 
				
			|||||||
    logger.debug('Initialize WakaReadme')
 | 
					    logger.debug('Initialize WakaReadme')
 | 
				
			||||||
    wk_c = WakaConstants()
 | 
					    wk_c = WakaConstants()
 | 
				
			||||||
    wk_i = WakaInput()
 | 
					    wk_i = WakaInput()
 | 
				
			||||||
    if not wk_i.validate_input():
 | 
					    if not (wk_i.validate_input() or wk_i.validate_constants()):
 | 
				
			||||||
        logger.error('Environment variables are misconfigured')
 | 
					        logger.error('Environment variables are misconfigured')
 | 
				
			||||||
        sys.exit(1)
 | 
					        sys.exit(1)
 | 
				
			||||||
    logger.debug('Input validation complete')
 | 
					    logger.debug('Input validation complete')
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user