Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
copyright = '2025, Rihaan Meher'
author = 'Rihaan Meher'

release = '1.1.0'
release = '1.2.0'
html_favicon = "_static/icon.png"

# -- General configuration ---------------------------------------------------
Expand All @@ -25,4 +25,4 @@
# https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output

html_theme = 'furo'
html_static_path = ['_static']
html_static_path = ['_static']
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Features
* **Header Files** In reStructuredPython, enjoy having the ability to create header files, similar to C++ for easier, and more organized development. View the `syntax <https://restructuredpython.readthedocs.io/en/latest/reference/Syntax_Guide.html>`_ guide for more details.
* **Seamless Compilation:** reStructuredPython code compiles directly into Python, ensuring compatibility with existing Python libraries and frameworks.
* **Enhanced Readability:** The syntax enhancements which include multiline comments aim to improve code readability and reduce verbosity.
* **repyconfig.toml:** Easily control the build of your projects with a repyconfig.toml

Documentation
-------------
Expand Down
1 change: 1 addition & 0 deletions docs/source/reference/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ The reference section provides detailed information about the built-in functions

Syntax_Guide
Builtin_Decorators
repyconfig.toml
36 changes: 36 additions & 0 deletions docs/source/reference/repyconfig.toml.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
repyconfig.toml Configuration Guide
===================================

The repyconfig.toml can be used to alter the default settings of the compiler in the following scenarios:
* If it is called via ``repy path/to/repyconfig.toml``

*Note: While the repyconfig.toml does not have to be in the root directory, all paths in the file must be relative to the directory of command execution, and must follow the schema such as for relative paths:* ``./path/to/file.repy``. *No backslashes allowed*

Introduced in 1.2.0, it has a very simple schema but will be expanded on jn future versions.

Example schema:

.. code-block:: toml

[config]
compile = "all"
exclude = ["./tests/*", "./docs/*"]

Explanation:

- ``compile = "all"``: Will compile all files in the root directory except those files/dirs mentioned in ``exclude``
- ``exclude = ["./tests/*", "./docs/*"]`` Will not compile these files/directories

Complete reference

Section ``config`` (1/1): Contains main information for the compiler

Key ``compile`` (1/2) Type: str: Contains information about what files to compile

``"all"``: Compiles all files in the given diretory, except those listed in the key ``exclude``

Key ``exclude`` (2/2) Type: List: A list of paths and directories to exclude.

Written as ``["./path/to/dir/", "./path/to/file.repy", ...]``

More items coming soon.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "restructuredpython"
version = "1.1.0"
version = "1.2.0"
description = "A superset of Python with js-like syntax"
authors = [{name = "Rihaan Meher", email = "meherrihaan@gmail.com"}]
license = {text = "MIT"}
Expand Down
3 changes: 3 additions & 0 deletions repyconfig.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[config]
compile = "all"
exclude = ["./tests/*", "./docs/*"]
4 changes: 2 additions & 2 deletions restructuredpython.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Metadata-Version: 2.4
Name: restructuredpython
Version: 1.1.0
Version: 1.2.0
Summary: A superset of Python with js-like syntax
Author-email: Rihaan Meher <meherrihaan@gmail.com>
License: MIT
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.19
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
65 changes: 51 additions & 14 deletions restructuredpython/restructuredpython.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,23 +255,63 @@ def main():
if not os.path.exists(input_file):
print(f"Error: The file {input_file} does not exist.")
return
if input_file.endswith('repyconfig.toml'):
import tomllib as toml
import fnmatch
with open(input_file, "rb") as file:
data = toml.load(file)
try:
compile_value = data["config"]["compile"]
except:
compile_value = "null"
print("[WARNING] Error reading compile value from config")
try:
exclude_files = data["config"]["exclude"]
except:
exclude_files = []
print("[WARNING] No excluded files found in config")
if compile_value == 'all':
extension = ".repy"
matching_files = []
for dirpath, _, filenames in os.walk("."):
for filename in filenames:
if filename.lower().endswith(extension.lower()):
file_path_temp = os.path.join(dirpath, filename)
if any(fnmatch.fnmatch(file_path_temp, pattern) for pattern in exclude_files):
continue
matching_files.append(file_path_temp)
for file_path_z in matching_files:
with open(file_path_z, 'r') as z:
source_code_z = z.read()

with open(input_file, 'r') as f:
source_code = f.read()
header_code_z, code_without_includes_z = process_includes(source_code_z, file_path_z)

header_code, code_without_includes = process_includes(
source_code, input_file)
python_code_z = parse_repython(code_without_includes_z)

python_code = parse_repython(code_without_includes)
final_code_z = header_code_z + python_code_z

final_code = header_code + python_code
output_file_z = os.path.splitext(file_path_z)[0] + '.py'

with open(output_file_z, 'w') as z:
z.write(final_code_z)
print(f"[DEBUG] Successfully compiled {file_path_z} to {output_file_z}")
else:
with open(input_file, 'r') as f:
source_code = f.read()

header_code, code_without_includes = process_includes(
source_code, input_file)

output_file = os.path.splitext(input_file)[0] + '.py'
python_code = parse_repython(code_without_includes)

with open(output_file, 'w') as f:
f.write(final_code)
final_code = header_code + python_code

print(f"Successfully compiled {input_file} to {output_file}")
output_file = os.path.splitext(input_file)[0] + '.py'

with open(output_file, 'w') as f:
f.write(final_code)

print(f"[DEBUG] Successfully compiled {input_file} to {output_file}")


def launch():
Expand Down Expand Up @@ -303,7 +343,4 @@ def launch():


if __name__ == "__main__":
main(1)

if __name__ == "__launch__":
main(2)
main()