Skip to content

Commit

Permalink
Merge pull request #363 from rasbt/docformatting
Browse files Browse the repository at this point in the history
Fix documentation parsing errors
  • Loading branch information
rasbt committed Apr 11, 2018
2 parents 740e53c + ff8748f commit 288c20e
Show file tree
Hide file tree
Showing 8 changed files with 236 additions and 153 deletions.
5 changes: 1 addition & 4 deletions docs/ipynb2markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,7 @@ def ipynb_to_md(ipynb_path):
if line.lstrip().startswith('#'):
break
for line in f:
if line.lstrip().startswith('```'):
continue
else:
new_s.append(line[4:])
new_s.append(line[4:])

with open(md_name, 'w') as f:
f.write(''.join(new_s))
Expand Down
15 changes: 12 additions & 3 deletions docs/make_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def docstring_to_markdown(docstring):
line = line.strip()
if set(line) in ({'-'}, {'='}):
new_docstring_lst[idx - 1] = '**%s**' % new_docstring_lst[idx - 1]

elif line.startswith('>>>'):
line = ' %s' % line
new_docstring_lst.append(line)
Expand All @@ -62,8 +63,16 @@ def docstring_to_markdown(docstring):

clean_lst = []
for line in new_docstring_lst:
if set(line.strip()) not in ({'-'}, {'='}):
if line.startswith('\n>>>'):
clean_lst.append('\n')
clean_lst.append(' ' + line[1:])
elif line.startswith(' ```'):
clean_lst.append(line[8:])
elif line.startswith(' ```'):
clean_lst.append(line[4:])
elif set(line.strip()) not in ({'-'}, {'='}):
clean_lst.append(line)

return clean_lst


Expand Down Expand Up @@ -338,7 +347,7 @@ def summarize_methdods_and_functions(api_modules, out_dir,
new_output = []
if str_above_header:
new_output.append(str_above_header)
for p in module_paths:
for p in sorted(module_paths):
with open(p, 'r') as r:
new_output.extend(r.readlines())

Expand Down Expand Up @@ -406,4 +415,4 @@ def summarize_methdods_and_functions(api_modules, out_dir,
clean=args.clean,
str_above_header=('mlxtend'
' version: %s \n' % (
package.__version__)))
package.__version__)))
27 changes: 23 additions & 4 deletions docs/sources/user_guide/evaluate/bootstrap_point632_score.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -201,17 +201,17 @@
"\n",
"**Examples**\n",
"\n",
"\n",
" >>> from sklearn import datasets, linear_model\n",
" >>> from mlxtend.evaluate import bootstrap_point632_score\n",
" >>> import numpy as np\n",
" >>> iris = datasets.load_iris()\n",
" >>> X = iris.data\n",
" >>> y = iris.target\n",
" >>> lr = linear_model.LogisticRegression()\n",
" >>> scores = bootstrap_point632_score(lr, X, y)\n",
" >>> acc = np.mean(scores)\n",
" >>> print('Accuracy:', acc)\n",
" Accuracy: 0.953023146884\n",
" 0.953023146884\n",
" >>> lower = np.percentile(scores, 2.5)\n",
" >>> upper = np.percentile(scores, 97.5)\n",
" >>> print('95%% Confidence interval: [%.2f, %.2f]' % (lower, upper))\n",
Expand All @@ -226,6 +226,13 @@
" s = f.read() \n",
"print(s)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -245,7 +252,19 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
"version": "3.6.4"
},
"toc": {
"nav_menu": {},
"number_sections": true,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
32 changes: 27 additions & 5 deletions docs/sources/user_guide/frequent_patterns/apriori.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@
},
{
"cell_type": "code",
"execution_count": 9,
"execution_count": 2,
"metadata": {},
"outputs": [
{
Expand All @@ -971,8 +971,9 @@
"\n",
"- `df` : pandas DataFrame\n",
"\n",
" pandas DataFrame in one-hot encoded format. For example\n",
" ```\n",
" pandas DataFrame the encoded format. For example,\n",
"\n",
"```\n",
" Apple Bananas Beer Chicken Milk Rice\n",
" 0 1 0 1 1 0 1\n",
" 1 1 0 1 0 0 1\n",
Expand All @@ -982,7 +983,8 @@
" 5 0 0 1 0 1 1\n",
" 6 0 0 1 0 1 0\n",
" 7 1 1 0 0 0 0\n",
" ```\n",
"```\n",
"\n",
"\n",
"- `min_support` : float (default: 0.5)\n",
"\n",
Expand All @@ -1005,7 +1007,8 @@
"**Returns**\n",
"\n",
"pandas DataFrame with columns ['support', 'itemsets'] of all itemsets\n",
" that are >= `min_support` and < than `max_len` (if `max_len` is not None).\n",
" that are >= `min_support` and < than `max_len`\n",
" (if `max_len` is not None).\n",
"\n",
"\n"
]
Expand All @@ -1015,6 +1018,13 @@
"with open('../../api_modules/mlxtend.frequent_patterns/apriori.md', 'r') as f:\n",
" print(f.read())"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
Expand All @@ -1035,6 +1045,18 @@
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
},
"toc": {
"nav_menu": {},
"number_sections": false,
"sideBar": true,
"skip_h1_title": false,
"title_cell": "Table of Contents",
"title_sidebar": "Contents",
"toc_cell": false,
"toc_position": {},
"toc_section_display": true,
"toc_window_display": false
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 288c20e

Please sign in to comment.