Skip to content

Commit

Permalink
Merge pull request #127 from IanCa/dev_docs_final
Browse files Browse the repository at this point in the history
Initial pass of javascript docs
  • Loading branch information
VisLab authored Oct 18, 2023
2 parents f55aaa8 + 67c57e4 commit 9a70218
Show file tree
Hide file tree
Showing 78 changed files with 718 additions and 136 deletions.
6 changes: 6 additions & 0 deletions common/schema/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ export class Schema {
tagHasAttribute(tag, tagAttribute) {}
}

/**
* Hed2Schema class
*/
export class Hed2Schema extends Schema {
/**
* The description of tag attributes.
Expand Down Expand Up @@ -91,6 +94,9 @@ export class Hed2Schema extends Schema {
}
}

/**
* Hed3Schema class
*/
export class Hed3Schema extends Schema {
/**
* The collection of schema entries.
Expand Down
4 changes: 3 additions & 1 deletion converter/splitHedString.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const tagDelimiters = new Set([',', '(', ')', '~'])
* @returns {Array[]} A list of string parts. The boolean is true if the part is
* a tag and false if it is a delimiter. The numbers are the bounds of the part.
*/
export default function splitHedString(hedString) {
export function splitHedString(hedString) {
const resultPositions = []
let currentSpacing = 0
let insideDelimiter = true
Expand Down Expand Up @@ -62,3 +62,5 @@ export default function splitHedString(hedString) {

return resultPositions
}

export default splitHedString
34 changes: 32 additions & 2 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
# Minimal makefile for Sphinx documentation
#
# We avoid $(CURDIR) because it spits out /cygdrive/c/... on Windows Cygwin
# installs and leads to things that don't work.
VIRTUAL_ENV = venv
PYTHON3 ?= python3

# Let us find jsdoc and sphinx:
export PATH := node_modules/.bin:$(VIRTUAL_ENV)/bin:$(VIRTUAL_ENV)/Scripts:$(PATH)

# I'm not entirely sure why this line is needed yet...
.PHONY: js

# Verify venv exists
.PHONY: venv
venv: $(VIRTUAL_ENV)/pyvenv.cfg

$(VIRTUAL_ENV)/pyvenv.cfg:
$(PYTHON3) -m venv $(VIRTUAL_ENV)
PATH="$(PATH)" pip3 install -r requirements.txt

# Not sure if this is needed...
# .npm_installed: ../package.json
# npm install
# touch $@

# You can set these variables from the command line, and also
# from the environment for the first two.
Expand All @@ -18,3 +39,12 @@ help:
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)



# Delete just the built docs, not the whole venv, which is expensive to
# reconstitute:
.PHONY: clean
clean:
rm -rf $(BUILDDIR)
rm -rf node_modules .npm_installed
13 changes: 13 additions & 0 deletions docs/source/bids.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bids
====

Bids functionality

.. toctree::
:maxdepth: 8

bids.schema.rst
bids.tsvParser.rst
bids.types.rst
bids.utils.rst
bids.validate.rst
3 changes: 2 additions & 1 deletion docs/source/api2.rst → docs/source/bids.schema.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
HED API reference (Auto style)
Schema
==============================

Intentionally Blank
5 changes: 5 additions & 0 deletions docs/source/bids.tsvParser.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tsvParse
==============================

.. js:autofunction:: parseTSV

23 changes: 23 additions & 0 deletions docs/source/bids.types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
types
==============================

.. js:autoclass:: BidsData
:members:

.. js:autoclass:: BidsFile
:members:

.. js:autoclass:: BidsJsonFile
:members:

.. js:autoclass:: BidsTsvFile
:members:

.. js:autoclass:: BidsEventFile
:members:

.. js:autoclass:: BidsTabularFile
:members:

.. js:autoclass:: BidsSidecar
:members:
5 changes: 5 additions & 0 deletions docs/source/bids.utils.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
utils
==============================

.. js:autofunction:: sidecarValueHasHed

22 changes: 22 additions & 0 deletions docs/source/bids.validate.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
validate
==============================

.. js:autofunction:: sidecarValueHasHed

.. js:autofunction:: validateBidsDataset

.. js:autofunction:: validateFullDataset

.. js:autofunction:: validateBidsTsvFile

.. js:autofunction:: validateSidecars

.. js:autofunction:: validateHedColumn

.. js:autofunction:: parseTsvHed

.. js:autofunction:: validateCombinedDataset

.. js:autofunction:: validateStrings

.. js:autofunction:: convertHedIssuesToBidsIssues
4 changes: 4 additions & 0 deletions docs/source/common.issues.data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
data
======

Intentionally blank for now
8 changes: 8 additions & 0 deletions docs/source/common.issues.issues.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
issues
======

.. js:autoclass:: Issue
:members:

.. js:autofunction:: generateIssue

8 changes: 8 additions & 0 deletions docs/source/common.issues.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
issues
======

.. toctree::
:maxdepth: 8

common.issues.issues
common.issues.data
8 changes: 8 additions & 0 deletions docs/source/common.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
common
======

.. toctree::
:maxdepth: 8

common.schema
common.issues
4 changes: 4 additions & 0 deletions docs/source/common.schema.config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
config
======

Intentionally blank for now
18 changes: 18 additions & 0 deletions docs/source/common.schema.loader.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
loader
======

.. js:autofunction:: loadSchema

.. js:autofunction:: loadSchemaFromSpec

.. js:autofunction:: loadPromise

.. js:autofunction:: loadRemoteSchema

.. js:autofunction:: loadLocalSchema

.. js:autofunction:: loadBundledSchema

.. js:autofunction:: loadSchemaFile

.. js:autofunction:: parseSchemaXML
9 changes: 9 additions & 0 deletions docs/source/common.schema.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
schema
======

.. toctree::
:maxdepth: 8

common.schema.types
common.schema.loader
common.schema.config
20 changes: 20 additions & 0 deletions docs/source/common.schema.types.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
types
======

.. js:autoclass:: Schema
:members:

.. js:autoclass:: Hed2Schema
:members:

.. js:autoclass:: Hed3Schema
:members:

.. js:autoclass:: Schemas
:members:

.. js:autoclass:: SchemaSpec
:members:

.. js:autoclass:: SchemasSpec
:members:
64 changes: 24 additions & 40 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import sys
import sphinx_rtd_theme
from datetime import date
import subprocess


sys.path.insert(0, os.path.abspath('../../../'))

Expand Down Expand Up @@ -42,30 +42,29 @@
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
"myst_parser",
"sphinx.ext.autodoc",
"sphinx.ext.autosummary",
"sphinx.ext.autosectionlabel",
"sphinx.ext.intersphinx",
"sphinx.ext.coverage",
"sphinx.ext.mathjax",
"sphinx.ext.viewcode",
"sphinx.ext.githubpages",
"sphinx.ext.napoleon",
"sphinx.ext.extlinks",
"sphinx_js"
# 'sphinx.ext.autodoc',
# 'sphinx.ext.viewcode',
# 'sphinx_click.ext',
'sphinx_js'
]

js_source_path = '../../'
root_for_relative_js_paths = "../../"
base_folders = ["../../bids", "../../validator", "../../converter", "../../common", "../../utils"]

primary_domain = 'js'
def find_all_folders(directory):
all_folders = [directory]

for root, dirs, _ in os.walk(directory):
for d in dirs:
all_folders.append(os.path.join(root, d))

autosummary_generate = True
autodoc_default_flags = ['members', 'inherited-members']
add_module_names = False
myst_all_links_external = False
myst_heading_anchors = 2
myst_enable_extensions = ["deflist"]
return all_folders

js_source_path = []
for folder in base_folders:
js_source_path += find_all_folders(folder)
print(js_source_path)
primary_domain = 'js'


# Add any paths that contain templates here, relative to this directory.
Expand All @@ -76,7 +75,7 @@
# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', '_templates', 'Thumbs.db', '.DS_Store']
exclude_patterns = ['_build', '_templates', 'Thumbs.db', '.DS_Store', 'venv']


# -- Options for HTML output -------------------------------------------------
Expand All @@ -100,29 +99,14 @@
# Toc options
'collapse_navigation': False,
'sticky_navigation': True,
'navigation_depth': 4,
'navigation_depth': 6,
'includehidden': True,
'titles_only': False
}
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']


def run_jsdoc(app):
source_dir = app.builder.srcdir
jsdoc_output_dir = os.path.join(source_dir, 'jsdoc_output')
jsdoc_command = [
'npx', # Use npx to run locally installed npm packages
'jsdoc',
'-c', os.path.join(source_dir, 'path/to/jsdoc/config.json'), # Adjust the path to your JSDoc config
'-d', jsdoc_output_dir,
'path/to/javascript/files', # Adjust the path to your JavaScript files
]
subprocess.call(jsdoc_command)

import sphinx_rtd_theme
html_static_path = [os.path.join(sphinx_rtd_theme.get_html_theme_path(), 'sphinx_rtd_theme', 'static')]

def setup(app):
app.connect('builder-inited', run_jsdoc)

18 changes: 18 additions & 0 deletions docs/source/converter.converter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
converter
=========

.. js:autofunction:: removeSlashesAndSpaces

.. js:autofunction:: convertTagToLong

.. js:autofunction:: convertTagToShort

.. js:autofunction:: convertPartialHedStringToLong

.. This one is not marked for export
.. js:autofunction:: convertHedString
.. js:autofunction:: convertHedStringToLong

.. js:autofunction:: convertHedStringToShort

4 changes: 4 additions & 0 deletions docs/source/converter.issues.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
issues
======

Intentionally blank for now
11 changes: 11 additions & 0 deletions docs/source/converter.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
converter
=========

.. toctree::
:maxdepth: 8

converter.types
converter.schema
converter.issues
converter.splitHedString
converter.converter
7 changes: 7 additions & 0 deletions docs/source/converter.schema.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
schema
=========

.. js:autofunction:: buildMappingObject

.. js:autofunction:: schema.buildSchema

Loading

0 comments on commit 9a70218

Please sign in to comment.