Closed Lakshmikanth2001 closed 2 years ago
Sir any updates
Hi @Lakshmikanth2001!
I'm sorry it's taken me so long to get back to you on this. I've been pretty preoccupied with crafting gifts for friends and family for the impending holiday season!
I took a look at the source, and I realized that you'd manually added links to the source code in GitHub in each of the functions. While this is very admirable work, I don't think it's very sustainable. With each new function, it will be necessary to not only remember to update the link, but also update all of the other links that may have been affected by the change in line numbers.
In short, I think that this will lead to ongoing headache for anyone involved.
I've done a little research, and found the standard Sphinx extension sphinx.ext.viewcode
which is more along the lines of what I thought you'd originally intended in #30.
I'm declining this PR, and will add the extension in a small PR so that the updates should be brought in. Thank you again for pressing onward with this issue, it's a great improvement, and I appreciate your continued drive.
Actually, I have developed a python script that adds line numbers to each function doing it manually would take days
if name == "main":
function_url = dict()
REMOTE_URL = "https://github.com/engineerjoe440/ElectricPy/blob/master/electricpy/"
#get only files electricpy directory
SOURCES = [file for file in os.listdir('electricpy') if os.path.isfile(os.path.join('electricpy', file))]
for source in SOURCES:
with open(os.path.join(sys.path[0], f"electricpy\{source}"), "r") as code:
# buid a regular expression for "def ()"
code = code.readlines()
blank_count = 0
RE = re.compile(r'def (.*)\(')
param_count = 0
function_count = 0
source_count = 0
# iterate over the lines in the file
for line_number, line in enumerate(code):
# find all the functions
function_name = RE.findall(line)
try:
if code[line_number+1].find(" Parameters") != -1:
line = add_source(list(function_url.values())[-1])
source_count += 3
continue
except IndexError:
pass
if line.find(" Parameters") != -1:
blank_count+=1
param_count += 1
# if there are any matches
if function_name:
# get the function name
function_name = function_name[0]
module = source.replace(".py", "")
if correct_doc(function_name, module):
function_count+=1
function_url[function_name] = f"{REMOTE_URL}{source}#L{line_number+1+source_count}"
logging.info(f"In {source} their are {function_count} functions with {param_count} parameters")
logging.info(f"In {source} there are {blank_count} blank lines above parameters")
I have tried to add the feature which I mentioned in #30
Please review this pull request