Skip to content

Commit 86c0029

Browse files
committed
wrote docs, I am a Pro now
1 parent c591326 commit 86c0029

File tree

6 files changed

+160
-6
lines changed

6 files changed

+160
-6
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ instance/
7373

7474
# Sphinx documentation
7575
docs/_build/
76+
docs/_static
77+
docs/_templates
7678

7779
# PyBuilder
7880
target/

coderunner/coderunner.py

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
"""coderunner helps you run your programs on Judge0's Server"""
1+
"""
2+
coderunner.py
3+
====================================
4+
The core module of CodeRunner
5+
"""
26
import requests
37

48
# language IDs on judge0, see README.md
@@ -22,10 +26,16 @@
2226

2327
class Run:
2428
"""
25-
Initialize program data like name,expected input/output etc
29+
Args:
30+
- Source Code path
31+
- Language
32+
- Expected Output File Path
33+
- Standard Input File Path
2634
"""
2735

2836
def __init__(self, program_name: str, lang: str, output: str, inp: str = None):
37+
"""Constructor method
38+
"""
2939
self.program_name = program_name
3040
self.lang = lang
3141
if lang not in languages:
@@ -40,9 +50,6 @@ def __init__(self, program_name: str, lang: str, output: str, inp: str = None):
4050
self.__stdout = None
4151

4252
def __readCode(self):
43-
"""
44-
Read Source Code & return as string
45-
"""
4653
with open(self.program_name, "r") as myfile:
4754
data = myfile.read()
4855
return data
@@ -90,18 +97,28 @@ def __submit(self):
9097
def getStandardOutput(self):
9198
"""
9299
Return the standard output of the program
100+
101+
:param: None
102+
:rtype: String
93103
"""
94104
return self.__stdout
95105

96106
def getMemory(self):
97107
"""
98-
Return the memory used by the program (in bytes)
108+
Return the memory used by the program (in kilobytes)
109+
110+
:param: None
111+
:return: Return the memory for eg 3564 KiloBytes
112+
:rtype: String
99113
"""
100114
return self.__memory
101115

102116
def getError(self):
103117
"""
104118
Return any error occured during program execution
119+
120+
:param: None
121+
:rtype: String
105122
"""
106123
if self.__response["stderr"] != "":
107124
return self.__response["stderr"]
@@ -110,12 +127,20 @@ def getError(self):
110127
def getTime(self):
111128
"""
112129
Return execution time used by the program
130+
131+
:param: None
132+
:return: Returns the execution time used by Source Code for e.g 0.037 secs
133+
:rtype: String
113134
"""
114135
return self.__time
115136

116137
def getStatus(self):
117138
"""
118139
Submits the program on Judge0's server and returns its status
140+
141+
:param: None
142+
:return: Returns either `Accepted` or `Run Time Error`
143+
:rtype: String
119144
"""
120145
self.program_name = self.__readCode()
121146
self.output = self.__readExpectedOutput()

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/conf.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
#
3+
# This file only contains a selection of the most common options. For a full
4+
# list see the documentation:
5+
# https://www.sphinx-doc.org/en/master/usage/configuration.html
6+
7+
# -- Path setup --------------------------------------------------------------
8+
9+
# If extensions (or modules to document with autodoc) are in another directory,
10+
# add these directories to sys.path here. If the directory is relative to the
11+
# documentation root, use os.path.abspath to make it absolute, like shown here.
12+
#
13+
import os
14+
import sys
15+
sys.path.insert(0, os.path.abspath('..'))
16+
17+
18+
# -- Project information -----------------------------------------------------
19+
20+
project = 'CodeRunner'
21+
copyright = '2019, Bhupesh Varshney'
22+
author = 'Bhupesh Varshney'
23+
24+
# The full version, including alpha/beta/rc tags
25+
release = '0.3'
26+
27+
28+
# -- General configuration ---------------------------------------------------
29+
30+
# Add any Sphinx extension module names here, as strings. They can be
31+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32+
# ones.
33+
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.coverage', 'sphinx.ext.napoleon']
34+
35+
# Add any paths that contain templates here, relative to this directory.
36+
templates_path = ['_templates']
37+
38+
# List of patterns, relative to source directory, that match files and
39+
# directories to ignore when looking for source files.
40+
# This pattern also affects html_static_path and html_extra_path.
41+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
42+
43+
44+
# -- Options for HTML output -------------------------------------------------
45+
46+
# The theme to use for HTML and HTML Help pages. See the documentation for
47+
# a list of builtin themes.
48+
#
49+
html_theme = 'alabaster'
50+
51+
# Add any paths that contain custom static files (such as style sheets) here,
52+
# relative to this directory. They are copied after the builtin static files,
53+
# so a file named "default.css" will overwrite the builtin "default.css".
54+
html_static_path = ['_static']

docs/index.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
Welcome to CodeRunner's documentation!
2+
======================================
3+
4+
.. automodule:: coderunner.coderunner
5+
:members:
6+
7+
.. toctree::
8+
:maxdepth: 2
9+
:caption: Contents:
10+
11+
12+
13+
Indices and tables
14+
==================
15+
16+
* :ref:`genindex`
17+
* :ref:`modindex`
18+
* :ref:`search`

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=.
11+
set BUILDDIR=_build
12+
13+
if "%1" == "" goto help
14+
15+
%SPHINXBUILD% >NUL 2>NUL
16+
if errorlevel 9009 (
17+
echo.
18+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19+
echo.installed, then set the SPHINXBUILD environment variable to point
20+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
21+
echo.may add the Sphinx directory to PATH.
22+
echo.
23+
echo.If you don't have Sphinx installed, grab it from
24+
echo.http://sphinx-doc.org/
25+
exit /b 1
26+
)
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

0 commit comments

Comments
 (0)