Skip to content

Commit

Permalink
Merge pull request #3 from radon-project/markdown-lint-issue
Browse files Browse the repository at this point in the history
fix: markdown lint issue and markdown file changes detection CI/CD.
  • Loading branch information
Almas-Ali authored May 31, 2024
2 parents 7698a32 + c6e73d2 commit 2ec9378
Show file tree
Hide file tree
Showing 26 changed files with 495 additions and 192 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
- name: Check for changes in docs/ or mkdocs.yml
id: check_changes
run: |
git diff --name-only > changed_files.txt
git diff --name-only origin/master -- > changed_files.txt
if grep -qE '(^docs/|^mkdocs.yml)' changed_files.txt; then
echo "changes_detected=true" >> $GITHUB_ENV
else
Expand Down
22 changes: 15 additions & 7 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: tests

on: [push, pull_request]
on: [push]

jobs:
build_and_test:
Expand All @@ -25,11 +25,13 @@ jobs:
- name: Check for changes in docs/ or mkdocs.yml
id: check_changes
run: |
git diff --name-only > changed_files.txt
if grep -qE '(^docs/|^mkdocs.yml)' changed_files.txt; then
echo "changes_detected=true" >> $GITHUB_ENV
else
if [ "$(git diff --quiet origin/master -- docs/ mkdocs.yml; echo $?)" -eq 0 ];
then
echo "changes_detected=false" >> $GITHUB_ENV
echo "No changes to docs/ and mkdocs.yml - exiting the build.";
else
echo "changes_detected=true" >> $GITHUB_ENV
echo "Changes detected in docs/ or mkdocs.yml - continuing the build.";
fi
- name: Set up Node.js
Expand All @@ -50,9 +52,15 @@ jobs:
if: env.changes_detected == 'true'
run: mkdocs build

- name: Install Ruby and Bundler
- name: Install Ruby
if: env.changes_detected == 'true'
uses: ruby/setup-ruby@v1
with:
ruby-version: '3.1'

- name: Install Bundler
if: env.changes_detected == 'true'
run: sudo apt-get install -y ruby-full
run: gem install bundler

- name: Install HTML Proofer
if: env.changes_detected == 'true'
Expand Down
12 changes: 12 additions & 0 deletions .markdownlint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"MD033": {
"allowed_elements": [
"figure",
"figcaption",
"a",
"strong",
"center"
]
},
"MD036": false
}
23 changes: 13 additions & 10 deletions docs/arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
- `arr_push(array, item)` - adds an item to the end of the array
- `arr_pop(array, index)` - removes an item from the end of the array
- `arr_append(array, item)` - adds an item to the end of the array
- `arr_extend(array1, array2)` - adds all the items of an array to the end of the array
- `arr_extend(array1, array2)` - adds all the items of an array to
the end of the array
- `arr_find(array, index)` - returns the item at the specified index
- `arr_slice(array, start, end)` - returns the items from the specified start index to the specified end index

- `arr_slice(array, start, end)` - returns the items from the specified
start index to the specified end index

```py linenums="1" title="methods.rn"
var arr = [1, 2, 3, 4, 5]
arr = [1, 2, 3, 4, 5]
print(arr_len(arr)) # 5

arr_push(arr, 6)
Expand All @@ -38,32 +40,33 @@ print(arr_slice(arr, 0, 5)) # [1, 2, 3, 4, 5]
- `*` (repetition)

```py linenums="1" title="operators.rn"
var arr1 = [1, 2, 3]
var arr2 = [4, 5, 6]
arr1 = [1, 2, 3]
arr2 = [4, 5, 6]

print(arr1 + arr2) # [1, 2, 3, 4, 5, 6]
print(arr1 * 2) # [1, 2, 3, 1, 2, 3]
```

## Array standard library

- `map(func)` - returns a new array with the result of calling the specified function on each item of the array
- `map(func)` - returns a new array with the result of calling the specified
function on each item of the array
- `append(item)` - adds an item to the end of the array
- `pop(index)` - removes an item from the end of the array
- `extend(list)` - adds all the items of an array to the end of the array
- `find(index)` - returns the item at the specified index
- `slice(start, end)` - returns the items from the specified start index to the specified end index
- `slice(start, end)` - returns the items from the specified start index to
the specified end index
- `len()` - returns the length of the array
- `is_empty()` - returns `true` if the array is empty, otherwise `false`
- `to_string()` - returns the string representation of the array
- `is_array()` - returns `true` if the value is an array, otherwise `false`


```py linenums="1" title="array-standard-library.rn"
include Array # Include the Array standard library

# Create an array instance using the Array class
var arr = Array([1, 2, 3, 4, 5])
arr = Array([1, 2, 3, 4, 5])

print(arr.len()) # 5
print(arr.is_empty()) # false
Expand Down
21 changes: 15 additions & 6 deletions docs/blog/hello-world.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,25 @@
# Hello World

*Date: 12 Sep 2023*

*Time: 2:39 AM (GMT+6)*

## Introduction

We are excited to announce the launch **Radon** - a new open source programming language for the modern world. The language is designed to be simple, fast, and safe while incorporating modern language features such as type inference, pattern matching, and more. A key goal of the language is to be easy to learn and use, while still being powerful enough to build complex applications. It is also designed to be easy to embed in other applications, and to be used as a scripting language. The language is currently in the early stages of development, and we are looking for contributors to help us build the language.
We are excited to announce the launch **Radon** -
a new open source programming language for the modern world.
The language is designed to be simple, fast, and safe while incorporating modern
language features such as type inference, pattern matching, and more.
A key goal of the language is to be easy to learn and use, while still being
powerful enough to build complex applications. It is also designed to be easy
to embed in other applications, and to be used as a scripting language.
The language is currently in the early stages of development, and we are
looking for contributors to help us build the language.

## About the author

[**Md. Almas Ali**][almas] is a software engineer and a programming language enthusiast. He is the creator of the Radon programming language. He has a lot of projects in his GitHub profile. Checkout his [GitHub profile][almas_github] for more information.
[**Md. Almas Ali**][almas] is a software engineer and a programming language
enthusiast. He is the creator of the Radon programming language. He has a lot
of projects in his GitHub profile. Checkout his [GitHub profile][almas_github]
for more information.

Created on: 12 Sep 2023 - 2:39 AM (GMT+6)

[almas]: https://almasali.net "Md. Almas Ali - Software Engineer"
[almas_github]: https://github.com/Almas-Ali "Md. Almas Ali on GitHub"
78 changes: 44 additions & 34 deletions docs/built-in-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,63 +2,73 @@

## Types of built-in functions

Built-in functions are the functions that are built into the language. They are used to perform common tasks. In Radon, there are a list of built-in functions that are available to use. They are:
Built-in functions are the functions that are built into the language.
They are used to perform common tasks. In Radon, there are a list of
built-in functions that are available to use.

They are:

### Utility methods

- `cls()` - clears the screen
- `clear()` - clears the screen
- `exit()` - exits the program
- `cls()` - clears the screen.
- `clear()` - clears the screen.
- `exit()` - exits the program.

### same as include statement
### Same as include statement

- `require()` - same as include statement to include a file or library in the current program
- `require()` - same as include statement to include a file or
library in the current program.

### Command line arguments

- `sys_args()` - returns the command line arguments
- `sys_args()` - returns the command line arguments.

### API methods

- `pyapi(string)` - A high-level Python API for Radon. It is used to call Python functions from Radon. (Development)
- `pyapi(string)` - A high-level Python API for Radon.
It is used to call Python functions from Radon. (Development)

### Typecase methods

- `int()` - converts any value to an integer
- `float()` - converts any value to a float
- `str()` - converts any value to a string
- `bool()` - converts any value to a boolean
- `type()` - returns the type of the value
- `int()` - converts any value to an integer.
- `float()` - converts any value to a float.
- `str()` - converts any value to a string.
- `bool()` - converts any value to a boolean.
- `type()` - returns the type of the value.

### Type checker methods

- `is_num()` - returns `true` if the value is a number, otherwise `false`
- `is_int()` - returns `true` if the value is an integer, otherwise `false`
- `is_float()` - returns `true` if the value is a float, otherwise `false`
- `is_str()` - returns `true` if the value is a string, otherwise `false`
- `is_bool()` - returns `true` if the value is a boolean, otherwise `false`
- `is_array()` - returns `true` if the value is an array, otherwise `false`
- `is_fun()` - returns `true` if the value is a function, otherwise `false`
- `is_num()` - returns `true` if the value is a number, otherwise `false`.
- `is_int()` - returns `true` if the value is an integer, otherwise `false`.
- `is_float()` - returns `true` if the value is a float, otherwise `false`.
- `is_str()` - returns `true` if the value is a string, otherwise `false`.
- `is_bool()` - returns `true` if the value is a boolean, otherwise `false`.
- `is_array()` - returns `true` if the value is an array, otherwise `false`.
- `is_fun()` - returns `true` if the value is a function, otherwise `false`.

### String methods

- `str_len()` - returns the length of the string
- `str_find(string, index)` - returns the character at the specified index
- `str_slice(string, start, end)` - returns the substring from the specified start index to the specified end index
- `str_len()` - returns the length of the string.
- `str_find(string, index)` - returns the character at the specified index.
- `str_slice(string, start, end)` - returns the substring from the specified
start index to the specified end index.

### I/O methods

- `print()` - prints the specified value to the console
- `print_ret()` - prints the specified value to the console and returns the value
- `input()` - reads a line from the console
- `input_int()` - reads an integer from the console
- `print()` - prints the specified value to the console.
- `print_ret()` - prints the specified value to the console
and returns the value.
- `input()` - reads a line from the console.
- `input_int()` - reads an integer from the console.

### Array methods

- `arr_len()` - returns the length of the array
- `arr_push(array, item)` - adds an item to the end of the array
- `arr_pop(array, index)` - removes an item from the end of the array
- `arr_append(array, item)` - adds an item to the end of the array
- `arr_extend(array1, array2)` - adds all the items of an array to the end of the array
- `arr_find(array, index)` - returns the item at the specified index
- `arr_slice(array, start, end)` - returns the items from the specified start index to the specified end index
- `arr_len()` - returns the length of the array.
- `arr_push(array, item)` - adds an item to the end of the array.
- `arr_pop(array, index)` - removes an item from the end of the array.
- `arr_append(array, item)` - adds an item to the end of the array.
- `arr_extend(array1, array2)` - adds all the items of an array to the end
of the array.
- `arr_find(array, index)` - returns the item at the specified index.
- `arr_slice(array, start, end)` - returns the items from the specified start
index to the specified end index.
56 changes: 38 additions & 18 deletions docs/classes.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
# Classes
# Classes and Objects

## Object Oriented Programming

Object Oriented Programming (OOP) is a programming paradigm that uses objects and their interactions to design and program applications. It is based on the concept of objects rather than just functions and procedures. These objects are organized into classes, which allow individual objects to be grouped together. Most modern programming languages including Java, C/C++, and Python are object-oriented languages, and many older programming languages now have object-oriented versions.
Object Oriented Programming (OOP) is a programming paradigm that uses objects
and their interactions to design and program applications. It is based on the
concept of objects rather than just functions and procedures. These objects
are organized into classes, which allow individual objects to be grouped
together. Most modern programming languages including Java, C/C++, and Python
are object-oriented languages, and many older programming languages now have
object-oriented versions.

In Radon, we also have support for OOP. We can create classes and objects. We can also create methods and fields.
In Radon, we also have support for OOP. We can create classes and objects.
We can also create methods and fields.

## Classes

Let's start by creating a class. We can create a class using the `class` keyword. It is followed by the name of the class and the body of the class. The body of the class is enclosed in curly braces.
Let's start by creating a class. We can create a class using the `class`
keyword. It is followed by the name of the class and the body of the class.
The body of the class is enclosed in curly braces.

```py linenums="1" title="classes.rn"
class Person {
Expand All @@ -18,55 +27,66 @@ class Person {

## Objects

Now that we have created a class, we can create an object. We can create an object by simply calling the class like as a function. It is followed by the name of the class and the arguments in parentheses. The arguments are optional.
Now that we have created a class, we can create an object. We can create an
object by simply calling the class like as a function. It is followed by the
name of the class and the arguments in parentheses. The arguments are optional.

```js linenums="1" title="objects.rn"
var person = Person()
person = Person();
```

## Fields

Fields are the variables that are declared inside a class. They are used to store data. They are also called instance variables because they are unique to each instance of the class. They are declared using the `var` keyword. It is followed by the name of the field and the type of the field. The type of the field is optional.
Fields are the variables that are declared inside a class. They are used to
store data. They are also called instance variables because they are unique
to each instance of the class. They are declared using the `var` keyword. It
is followed by the name of the field and the type of the field.
The type of the field is optional.

```js linenums="1" title="fields.rn"
class Person {
var name = "John"
var age = 20
name = "John"
age = 20
}
```

## Constructors

Constructors are special methods that are used to initialize the fields of a class. They are called when an object is created. They are declared using the `fun` keyword. It is followed by the name (class name) of the constructor and the parameters in parentheses. The parameters are optional.
Constructors are special methods that are used to initialize the fields of a
class. They are called when an object is created. They are declared using the
`fun` keyword. It is followed by the name (class name) of the constructor and
the parameters in parentheses. The parameters are optional.

```js linenums="1" title="constructors.rn"
class Person {
fun Person(name, age) {
var this.name = name
var this.age = age
this.name = name
this.age = age
}
}

var person = Person("John", 20)
person = Person("John", 20)
```

## Methods

Methods are the functions that are declared inside a class. They are used to define the behavior of the class. They are declared using the `fun` keyword. It is followed by the name of the method, the parameters in parentheses, and the return type. The parameters and the return type are optional.
Methods are the functions that are declared inside a class. They are used to
define the behavior of the class. They are declared using the `fun` keyword.
It is followed by the name of the method, the parameters in parentheses, and
the return type. The parameters and the return type are optional.

```py linenums="1" title="methods.rn"
class Person {
fun Person(name, age) {
var this.name = name
var this.age = age
this.name = name
this.age = age
}

fun sayHello() {
print("Hello, " + this.name + "!")
}
}

var person = Person("John", 20)
person = Person("John", 20)
person.sayHello() # Output: Hello, John!

```
Loading

0 comments on commit 2ec9378

Please sign in to comment.