Skip to content

Commit

Permalink
Adding support for image markdown.
Browse files Browse the repository at this point in the history
Okay, so images were already supported but we will now have more functionality.
Moved parser from MooseCarousel to MooseCommon, as we will be using it from multiple extensions.
Adjust moose.css for better looking admonitions.
Fix markdown in documentation/creation.md.
Address andrew's comments. Remove table element generation for now.
Remove duplicate settings parser. Stop using <pre> tags in markdown.
Adding additional functionality to image parsing.
Added a very small (I will add more later) example of how to use the image parser.

Refs idaholab#7646
  • Loading branch information
milljm committed Sep 1, 2016
1 parent b9b978e commit b168b40
Show file tree
Hide file tree
Showing 14 changed files with 222 additions and 99 deletions.
18 changes: 9 additions & 9 deletions docs/content/getting_started/build_libmesh.md
Expand Up @@ -2,10 +2,10 @@
## Compile libMesh
* MOOSE directly relies on the libMesh finite-element framework. Because of this strong tie MOOSE contains a particular version of libMesh that we have vetted for our users. We will periodically update that version (about once a month) so stay tuned to the MOOSE-users mailing list for those announcements. To pull down and compile this version of libMesh you simply need to run a script in MOOSE:

<pre>
cd ~/projects/moose
scripts/update_and_rebuild_libmesh.sh
</pre>
```bash
cd ~/projects/moose
scripts/update_and_rebuild_libmesh.sh
```

!!! Important
Do not use `sudo` when running update_and_rebuild_libmesh.sh.
Expand All @@ -14,11 +14,11 @@
## Test It!
* All that's left is to make sure that everything is working properly...

<pre>
cd ~/projects/moose/test
make -j 4
./run_tests -j 4
</pre>
```bash
cd ~/projects/moose/test
make -j 4
./run_tests -j 4
```

* If everything is good then all of the tests will pass.

Expand Down
14 changes: 7 additions & 7 deletions docs/content/getting_started/clone_moose.md
Expand Up @@ -2,13 +2,13 @@
## Clone MOOSE
* MOOSE is hosted on GitHub and can be cloned directly from there using Git. We recommend creating a directory named projects to put all of your MOOSE related work in which leads to the following commands (from your home directory):

<pre>
mkdir ~/projects
cd ~/projects
git clone https://github.com/idaholab/moose.git
cd ~/projects/moose
git checkout master
</pre>
```bash
mkdir ~/projects
cd ~/projects
git clone https://github.com/idaholab/moose.git
cd ~/projects/moose
git checkout master
```

!!! note
The master branch of MOOSE is the stable branch that will only be updated after all tests are passing. This protects you from the day-to-day churn in the MOOSE repository
10 changes: 5 additions & 5 deletions docs/content/getting_started/conclusion.md
Expand Up @@ -17,11 +17,11 @@

* Update your copy of MOOSE for the latest features and fixes.

<pre>
cd ~/projects/moose
git fetch origin
git rebase origin/master
</pre>
```bash
cd ~/projects/moose
git fetch origin
git rebase origin/master
```

---
## Create an App
Expand Down
4 changes: 2 additions & 2 deletions docs/content/moose_tools/memory_logger.md
Expand Up @@ -194,7 +194,7 @@ Date Stamp Memory Usage | Percent of MAX memory used: ( 264,256
Okay... A bit too accurate, as several samples remained unchanged during tracking. However sometimes more is desirable, though just not printed in this fashion. For data dumps like this, using Matplotlib is far more efficient.

## Using Matplotlib
!image memory_logger-plot_multi.png width=300 align=right
!image memory_logger-plot_multi.png width=300 float=right

We can visualize the results by plotting the data with Matplotlib:
```text
Expand Down Expand Up @@ -233,7 +233,7 @@ You can also display stdout along the Matplotlib graph:
```text
memory_logger.py --pstack --stdout --plot simple_diffusion_memory.log
```
!image memory_logger-darkmode.png width=300 align=right
!image memory_logger-darkmode.png width=300 float=right

That white back ground to bright for you? Try dark mode:
```text
Expand Down
10 changes: 5 additions & 5 deletions docs/content/utilities/documentation/create.md
Expand Up @@ -27,7 +27,7 @@ of the `InputParameters` object. For example, in the [FunctionIC](../systems/fra
the following parameter documentation is added, which is then present in the parameter summary table of the
generated site.

![](framework/src/ics/FunctionIC.C line=addRequiredParam)
!text framework/src/ics/FunctionIC.C line=addRequiredParam

The string supplied in this function will appear in the parameter tables within the documentation that is generated.
For example, see the parameter table for the [DirichletBC object](/BCs/DirichletBC.md).
Expand All @@ -36,7 +36,7 @@ Secondly, a short description should be supplied in each `addParam`, `addPrivate
example, in the [Diffusion](/Kernels/Diffusion.md) object the following class
description.

![](framework/src/kernels/Diffusion.C line=addClassDescription)
!text framework/src/kernels/Diffusion.C line=addClassDescription

When the documentation for this object is generated this string is added to the first portion of the page and the
system overview table. For example, the [Kernels overview](/Kernels/Overview.md) includes a table with each object
Expand Down Expand Up @@ -82,7 +82,7 @@ The include option contains the information that indicates what documentation sh
the MOOSE documentation the following is contained within this option to build the documentation from the framework itself
as well as the phase field module.

![](docs/moosedocs.yml start=include end=contact:)
!text docs/moosedocs.yml start=include end=contact:

The names provided in the sub-sections (i.e., "framework" and "phase_field") are arbitrary. All of the options listed
in the table above may be used within each of the sub-sections to taylor the generation of the pages as needed to
Expand All @@ -97,7 +97,7 @@ the docs directory. The information within this file mimics the [mkdocs pages](h
configuration, with one exception: it is possible to include other markdown files. For example, the "pages.yml" for
the MOOSE website includes the following.

![](docs/pages.yml)
!text docs/pages.yml

Notice, that the framework and the modules each have include statements pointing to another "pages.yml" file. This
file is generated for each item in the "include" setting discussed above and is placed in the "install" directory.
Expand All @@ -115,7 +115,7 @@ The [mkdocs] uses the python [markdown](http://pythonhosted.org/Markdown/) packa
necessary functionality. This custom extension is located in `python/MooseDocs/extensions/MooseMarkdown.py` and includes
three configuration options, which are set as done in the `mkdocs.yml` file.

![](docs/mkdocs.yml start=markdown_extensions)
!text docs/mkdocs.yml start=markdown_extensions

| Option | Description |
| ------ | ----------- |
Expand Down
Expand Up @@ -173,3 +173,12 @@ A full slideshow example might be:
images/other*.png caption=Other images
images/more*.png
```

## Images
You can include images in your documentation by use of the !image markdown syntax:

```markdown
!image memory_logger-plot_multi.png width=300 align=right caption=figure 1
```
!image memory_logger-plot_multi.png width=300 align=right caption=figure 1

65 changes: 46 additions & 19 deletions docs/css/moose.css
@@ -1,35 +1,62 @@
.admonition-title {
margin: -15px;
font-weight: bold;
display: block;
padding: 6px 12px;
color: #fff;
margin-bottom: 12px;
border: 0px solid transparent;
}
.info .admonition-title {
background: #528452;
}
.admonition.info {
color: #186a3b;
background-color: #82e0aa;
border-color: #82e0aa;
background: #82e0aa;
color: #000;
border: 0px solid transparent;
}

.note .admonition-title {
background: #3a7296;
}
.admonition.note {
color: #1b4f72 ;
background-color: #85c1e9;
border-color: #85c1e9;
background: #85c1e9;
color: #000;
border: 0px solid transparent;
}

.important .admonition-title {
background: #b100b0;
}
.admonition.important {
color: #000000;
background-color: #FF00FF;
border-color: #FF00FF;
background: #FF00FF;
color: #000;
border: 0px solid transparent;
}

.warning .admonition-title {
background: #968b2b;
}
.admonition.warning {
color: #9c640c;
background-color: #fff9c4;
border-color: #fff9c4
background: #ffec46;
color: #000;
border: 0px solid transparent;
}

.danger .admonition-title {
background: #b14d00;
}
.admonition.danger {
color: #6e2c00;
background-color: #ffb74d;
border-color: #ffb74d;
background: #f75e1d;
color: #000;
border: 0px solid transparent;
}

.admonition.error {
color: #000000;
background-color: #ff0000;
border-color: #ff0000;
.error .admonition-title {
background: #940000;
}
.admonition.error {
background: #ffb4b4;
color: #000;
border: 0px solid transparent;
}
2 changes: 2 additions & 0 deletions docs/mkdocs.yml
Expand Up @@ -2,6 +2,8 @@ site_name: MOOSE

docs_dir: .

media_dir: ../media

site_dir: ../site

repo_url: https://github.com/idaholab/moose/
Expand Down
22 changes: 1 addition & 21 deletions python/MooseDocs/extensions/MooseCarousel.py
Expand Up @@ -19,30 +19,10 @@ class MooseCarousel(BlockProcessor, MooseCommonExtension):
"""

RE = re.compile(r'^!\ ?slideshow(.*)')
SETTINGS_RE = re.compile("([^\s=]+)=(.*?)(?=(?:\s[^\s=]+=|$))")
# If there are multiple carousels on the same page then
# they need to have different ids
MATCHES_FOUND = 0

def parseOptions(self, settings_line):
"""
Parses a string of space seperated key=value pairs.
This supports having values with spaces in them.
So something like "key0=foo bar key1=value1"
is supported.
Input:
settings_line[str]: Line to parse
Returns:
dict of values that were parsed
"""
matches = self.SETTINGS_RE.findall(settings_line.strip())
if not matches:
return {}
options = {}
for entry in matches:
options[entry[0].strip()] = entry[1].strip()
return options

def parseFilenames(self, filenames_block):
"""
Parse a set of lines with filenames in them and an optional caption.
Expand Down Expand Up @@ -97,7 +77,7 @@ def run(self, parent, blocks):
if m:
# Parse out the options on the slideshow line
options = m.group(1)
parsed_options = self.parseOptions(options)
parsed_options = self.getSettings(options)
block = block[m.end() + 1:] # removes the slideshow line

block, theRest = self.detab(block)
Expand Down
47 changes: 32 additions & 15 deletions python/MooseDocs/extensions/MooseCommonExtension.py
Expand Up @@ -16,25 +16,42 @@ class MooseCommonExtension(object):
def __init__(self):
self._settings = dict() # The default settings should be stored here

def getSettings(self, settings):
def checkFilename(self, rel_filename):
"""
Return the settings captured from the regular expression.
Checks that the filename exists, if it does not a error Element is return.
Args:
settings[str]: A string containing the space separate key, value pairs (key=value key2=value2).
filename[str]: The filename to check for existence.
"""
output = copy.copy(self._settings)
for s in settings.split(' '):
if s:
k, v = s.strip().split('=')
if k not in output:
log.warning('Unknown setting {}'.format(k))
continue
try:
output[k] = eval(v)
except:
output[k] = str(v)
return output

filename = os.path.abspath(os.path.join(self._root, rel_filename))
if os.path.exists(filename):
return filename
return None

def getSettings(self, settings_line):
"""
Parses a string of space seperated key=value pairs.
This supports having values with spaces in them.
So something like "key0=foo bar key1=value1"
is supported.
Input:
settings_line[str]: Line to parse
Returns:
dict of values that were parsed
"""

# Crazy RE capable of many things
# like understanding key=value pairs with spaces in them!
SETTINGS_RE = re.compile("([^\s=]+)=(.*?)(?=(?:\s[^\s=]+=|$))")
matches = SETTINGS_RE.findall(settings_line.strip())

if not matches:
return {}
options = copy.copy(self._settings)
for entry in matches:
options[entry[0].strip()] = entry[1].strip()
return options

def createErrorElement(self, rel_filename='', message=None):
"""
Expand Down

0 comments on commit b168b40

Please sign in to comment.