Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/AmitSharma512/talawa-admin
Browse files Browse the repository at this point in the history
… into Profile-picture
  • Loading branch information
AmitSharma512 committed Jan 7, 2024
2 parents b384f91 + e04e50a commit 0e7b92a
Show file tree
Hide file tree
Showing 31 changed files with 1,113 additions and 567 deletions.
97 changes: 97 additions & 0 deletions .github/workflows/md_mpx_format_adjuster.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Script to make Markdown files MPX compatible.
This script scans Markdown files and escapes special characters (<, >, {, })
to make them compatible with the MPX standard used in Docusaurus v3.
This script complies with:
1) Pylint
2) Pydocstyle
3) Pycodestyle
4) Flake8
"""

import os
import argparse
import re

def escape_mpx_characters(text):
"""
Escape special characters in a text string for MPX compatibility.
Avoids escaping already escaped characters.
Args:
text: A string containing the text to be processed.
Returns:
A string with special characters (<, >, {, }) escaped, avoiding
double escaping.
"""
# Regular expressions to find unescaped special characters
patterns = {
"<": r"(?<!\\)<",
">": r"(?<!\\)>",
"{": r"(?<!\\){",
"}": r"(?<!\\)}"
}

# Replace unescaped special characters
for char, pattern in patterns.items():
text = re.sub(pattern, f"\\{char}", text)

return text

def process_file(filepath):
"""
Process a single Markdown file for MPX compatibility.
Args:
filepath: The path to the Markdown file to process.
Returns:
None, writes the processed content back to the file only if there are changes.
"""
with open(filepath, 'r', encoding='utf-8') as file:
content = file.read()

# Escape MPX characters
new_content = escape_mpx_characters(content)

# Write the processed content back to the file only if there is a change
if new_content != content:
with open(filepath, 'w', encoding='utf-8') as file:
file.write(new_content)

def main():
"""
Main function to process all Markdown files in a given directory.
Scans for all Markdown files in the specified directory and processes each
one for MPX compatibility.
Args:
None
Returns:
None
"""
parser = argparse.ArgumentParser(description="Make Markdown files MPX compatible.")
parser.add_argument(
"--directory",
type=str,
required=True,
help="Directory containing Markdown files to process."
)

args = parser.parse_args()

# Process each Markdown file in the directory
for root, _, files in os.walk(args.directory):
for file in files:
if file.lower().endswith(".md"):
process_file(os.path.join(root, file))

if __name__ == "__main__":
main()
11 changes: 8 additions & 3 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,14 @@ jobs:

- name: Generate Documentation of Markdown pages
run: |
yarn global add typedoc
yarn add typedoc-plugin-markdown
yarn typedoc --entryPoints src/components src/screens --out talawa-admin-docs --plugin typedoc-plugin-markdown --theme markdown --entryPointStrategy expand --exclude "**/*.test.ts" --exclude "**/*.css"
npm install --global typedoc
npm install typedoc-plugin-markdown
npm install --save-dev @types/node
npx typedoc --entryPoints src/components src/screens --out talawa-admin-docs --plugin typedoc-plugin-markdown --theme markdown --entryPointStrategy expand --exclude "**/*.test.ts" --exclude "**/*.css"
- name: Make Markdown Files MPX Compatible
run: python ./.github/workflows/md_mpx_format_adjuster.py --directory talawa-admin-docs


- name: Checking doc updated
id: DocUpdated
Expand Down
5 changes: 3 additions & 2 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

npm run format:fix
npm run lint:fix
# npm run format:fix
# npm run lint:fix
npm run lint-staged
npm run typecheck
npm run update:toc

Expand Down
4 changes: 4 additions & 0 deletions .lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"**/*.{ts,tsx,yml}": "eslint --fix",
"**/*.{ts,tsx,json,scss,css,yml}": "prettier --write"
}
6 changes: 3 additions & 3 deletions CODE_STYLE.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ Follow this [link](https://getbootstrap.com/docs/5.3/customize/sass/) to learn h

**File Structure**

- `src/assets/scss/components/{partialFile}.scss` - where the {partialFile} are the following files
- `src/assets/scss/components/{'{partialFile}'}.scss` - where the {'{partialFile}'} are the following files
- **_accordion.scss**
- **_alert.scss**
- **_badge.scss**
Expand All @@ -209,12 +209,12 @@ Follow this [link](https://getbootstrap.com/docs/5.3/customize/sass/) to learn h
- **_progress.scss**
- **_spinners.scss**

- `src/assets/scss/content/{partialFile}.scss` - where the {partialFile} are the following files
- `src/assets/scss/content/{'{partialFile}'}.scss` - where the {'{partialFile}'} are the following files
- **_table.scss**
- **_typography.scss**


- `src/assets/scss/forms/{partialFile}.scss` - where the {partialFile} are the following files
- `src/assets/scss/forms/{'{partialFile}'}.scss` - where the {'{partialFile}'} are the following files
- **_check-radios.scss**
- **_floating-label.scss**
- **_form-control.scss**
Expand Down
Loading

0 comments on commit 0e7b92a

Please sign in to comment.