Commit 69b78d65 authored by Markus Scheidgen's avatar Markus Scheidgen
Browse files

Small improvements to markdown in UI and metainfo browser.

parent 9d4d0250
Pipeline #102322 passed with stages
in 24 minutes and 48 seconds
......@@ -257,28 +257,25 @@ function Markdown(props) {
// - turn metainfo names into links into the metainfo
let word = ''
content = children.replace(/^ +/gm, '').split('').map((c, i) => {
if (c === '$') {
if (state[state.length - 1] === 'math') {
if (c === '`' || c === '$') {
if (state.peek === c) {
state.pop()
} else {
state.push('math')
}
} else if (c === '`' || c === '(' || c === ')') {
if (state[state.length - 1] === 'code') {
state.pop()
} else {
state.push('code')
}
} else {
if (state.peek === 'escape') {
state.pop()
state.push(c)
}
}
if (!state[state.length - 1] && c.match(/[a-zA-Z0-9_]/)) {
if (c === '[') {
state.push(c)
}
if (c === ']' && state.peek === '[') {
state.pop()
}
if (c.match(/[a-zA-Z0-9_]/)) {
word += c
} else {
if (word.match(/_/g)) {
if (state.length === 0 && (word.match(/_/g) || word.match(/[a-z]+[A-Z]/g)) && word.match(/^[a-zA-Z0-9_]+$/g) && c !== ']') {
const path = metainfoPath(word)
if (path) {
word = `[\`${word}\`](/metainfo/${metainfoPath(word)})`
......
......@@ -133,13 +133,12 @@ Browser.propTypes = ({
export const laneContext = React.createContext()
const useLaneStyles = makeStyles(theme => ({
root: {
minWidth: 200,
maxWidth: 512,
width: 'min-content',
borderRight: `solid 1px ${grey[500]}`,
display: 'block'
display: 'inline-block'
},
container: {
display: 'block',
display: 'inline-block',
height: '100%',
overflowY: 'scroll'
},
......
......@@ -156,7 +156,7 @@ export function isReference(property) {
export function path(nameOrDef) {
let def
if (typeof nameOrDef === 'string') {
def = defsByName[nameOrDef] && defsByName[nameOrDef].find(def => def.m_def !== 'SubSection')
def = defsByName[nameOrDef] && defsByName[nameOrDef].find(def => true)
} else {
def = nameOrDef
}
......@@ -165,6 +165,10 @@ export function path(nameOrDef) {
return null
}
if (def.m_def === 'SubSection') {
def = resolveRef(def.sub_section)
}
if (def.m_def === 'Category') {
return `${def._package.name.split('.')[0]}/category_definitions@${def._qualifiedName}`
}
......
......@@ -1118,8 +1118,8 @@ class BasisSet(MSection):
dependent to the simulated cell as a whole).
Basis sets used in this section_single_configuration_calculation, belonging to either
class, are defined in the dedicated section: [section_basis_set_cell_dependent
](section_basis_set_cell_dependent) or section_basis_set_atom_centered. The
class, are defined in the dedicated section: section_basis_set_cell_dependent or
section_basis_set_atom_centered. The
correspondence between the basis sets listed in this section and the definition given
in the dedicated sessions is given by the two concrete metadata:
mapping_section_basis_set_cell_dependent and mapping_section_basis_set_atom_centered.
......@@ -1961,9 +1961,8 @@ class FrameSequenceUserQuantity(MSection):
Dedicated metadata monitored along a sequence of frames are created for the
conserved energy-like quantity (frame_sequence_conserved_quantity), the kinetic
and potential energies ([frame_sequence_kinetic_energy and
frame_sequence_potential_energy](frame_sequence_kinetic_energy and
frame_sequence_potential_energy)), the instantaneous temperature
and potential energies (frame_sequence_kinetic_energy and
frame_sequence_potential_energy), the instantaneous temperature
(frame_sequence_temperature) and the pressure (frame_sequence_pressure).
''',
categories=[Unused],
......@@ -3821,8 +3820,7 @@ class Run(MSection):
'''
Every section_run represents a single call of a program. What exactly is contained in
a run depends on the run type (see for example section_method and
section_single_configuration_calculation) and the program (see [program_info
](program_info)).
section_single_configuration_calculation) and the program (see ProgramInfo).
'''
m_def = Section(
......@@ -7859,7 +7857,7 @@ class Topology(MSection):
description='''
A unique string idenfiying the force field defined in this section. Strategies to
define it are discussed in the
[topology\\_force\\_field\\_name](https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-
[topology_force_field_name](https://gitlab.mpcdf.mpg.de/nomad-lab/nomad-meta-
info/wikis/metainfo/topology-force-field-name).
''',
a_legacy=LegacyDefinition(name='topology_force_field_name'))
......
......@@ -796,7 +796,13 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas
if isinstance(attr, Property):
attr.name = name
if attr.description is not None:
attr.description = inspect.cleandoc(attr.description).strip()
description = inspect.cleandoc(attr.description)
description = description.strip()
description = re.sub(
r'\(https?://[^\)]*\)',
lambda m: re.sub(r'\n', '', m.group(0)),
description)
attr.description = description
attr.__doc__ = attr.description
if isinstance(attr, Quantity):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment