From cc2753dc2dac15c3543ba77bd8e775a03a41b730 Mon Sep 17 00:00:00 2001 From: Schefflera-Arboricola <1509aditi@gmail.com> Date: Sat, 16 Mar 2024 21:13:22 +0530 Subject: [PATCH] updated par_params --- CONTRIBUTING.md | 6 ++++-- _nx_parallel/__init__.py | 27 +++++++++++++++++---------- 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21c42d9..aa3ab69 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -91,13 +91,15 @@ def betweenness_centrality( Parameters ------------ [EVERYTHING BELOW THIS LINE AND BEFORE THE NETWORKX LINK WILL BE DISPLAYED IN ADDITIONAL PARAMETER'S SECTION ON NETWORKX MAIN DOCS] get_chunks : function (default = "chunks") - A function that takes in nodes as input and returns node_chuncks + A function that takes in nodes as input and returns node_chunks...[YOU CAN MULTIPLE PARAGRAPHS FOR EACH PARAMETER, IF NEEDED, SEPARATED BY 1 BLANK LINE] + + [LEAVE 2 BLANK LINES BETWEEN EACH PARAMETER] parameter 2 : int .... . . . - + [LEAVE 1 BLANK LINE BETWEEN THE PARAMETERS SECTION AND THE LINK] networkx.betweenness_centrality : https://networkx.org/documentation/stable/reference/algorithms/generated/networkx.algorithms.centrality.betweenness_centrality.html """ ``` diff --git a/_nx_parallel/__init__.py b/_nx_parallel/__init__.py index 6d61ea4..9657a87 100644 --- a/_nx_parallel/__init__.py +++ b/_nx_parallel/__init__.py @@ -33,9 +33,7 @@ def get_funcs_info(): funcs[func] = { "url": get_url(path, func), "additional_docs": par_docs, - "additional_parameters": { - par_params, - }, + "additional_parameters": par_params, } return funcs @@ -82,22 +80,31 @@ def extract_from_docs(docstring): par_docs = "\n".join(par_docs_) except IndexError: par_docs = None + except Exception as e: + print(e) + par_docs = None try: # Extracting extra parameters # Assuming that the last para in docstring is the function's extra params - par_params_ = docstring.split("------------")[1] + par_params = {} + par_params_ = docstring.split("------------\n")[1] - par_params_ = par_params_.split("\n") - par_params_ = [line.strip() for line in par_params_ if line.strip()] - par_params = "\n".join( - par_params_[:-1] - ) # removing last line with the networkx link + par_params_ = par_params_.split("\n\n\n") + for i in par_params_: + j = i.split("\n") + par_params[j[0]] = "\n".join( + [line.strip() for line in j[1:] if line.strip()] + ) + if i == par_params_[-1]: + par_params[j[0]] = "\n".join( + [line.strip() for line in j[1:-1] if line.strip()] + ) except IndexError: par_params = None except Exception as e: print(e) - par_docs = None + par_params = None return par_docs, par_params