Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 59353c0

Browse files
committed
Add docs/index.md describing how to add support for a new language and the inner workings of the openleetcode script.
1 parent c8fbaf1 commit 59353c0

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

‎docs/index.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# Getting Started
2+
3+
Welcome to the OpenLeetCode Project! This guide will describe how to add support for a new language.
4+
5+
## Table of Contents
6+
7+
1. [Adding support for a new language](#adding-support-for-a-new-language)
8+
2. [Building and Running the Testcases](#building-and-running-the-testcases)
9+
3. [Schema Validation](#schema-validation)
10+
11+
## Adding support for a new language
12+
13+
The support for each language should be self contained within its own folder, located in ``problems_build/problems/language/<language>``. For example, for C++ there is a folder ``cpp`` as shown below:
14+
15+
- problem_builds
16+
- problems
17+
- launguage
18+
- cpp
19+
- java
20+
- python
21+
22+
Any newly added language must adhere to the guidelines in the following sections.
23+
24+
## Building and Running the Testcases
25+
26+
#### Setup
27+
When ``openleetcode`` is executed, two of the specified parameters are ``problem`` and ``language``. In this example, let's assume the problem is ``TwoSum`` and the language is ``Cpp``.
28+
29+
``openleetcode`` copies all files from ``problems_build/language/cpp`` into the ``problems_build/problems/TwoSum/cpp``, including source files and CMake files. The folder already contains ``solution.cpp`` in the case of C++ laguage.
30+
31+
#### Build and Run
32+
Once the copying is complete, CMake is executed to build the binary and subsequently run it against the specified test cases from ``problems_build/problems/TwoSum/testcases.``.
33+
34+
#### The Results
35+
The results of this run will be stored inside ``problems_build/problems/TwoSum/cpp/testcase_output/TwoSum-<datetime>.results``.
36+
37+
38+
## Schema Validation
39+
Once ``openleetcode`` executes the built binary against the testcases, it then picks up the results file and adds two properties: ``stderr`` and ``stdout`` then write it back to its original location. The ``.result`` file is in a json format specified by a validation schema that is used to validate this results file. The validation schema can be found in ``testcase_output/results_validation_schema.json``.
40+
41+
Once ``openleetcode`` executes the built binary against the test cases, it then retrieves the results file and adds two properties: ``stderr`` and ``stdout`` before writing it back to its original location. The ``.result`` file is in JSON format, as specified by a validation schema in ``testcase_output/results_validation_schema.json``. This schema is also used to validating the results file.
42+
43+
Note: Schema validation ensures consistent formatting of the results file for multiple languages. A UI component will rely on the results file being in a consistent format, regardless of the programming language.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /