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) { ...@@ -257,28 +257,25 @@ function Markdown(props) {
// - turn metainfo names into links into the metainfo // - turn metainfo names into links into the metainfo
let word = '' let word = ''
content = children.replace(/^ +/gm, '').split('').map((c, i) => { content = children.replace(/^ +/gm, '').split('').map((c, i) => {
if (c === '$') { if (c === '`' || c === '$') {
if (state[state.length - 1] === 'math') { if (state.peek === c) {
state.pop() state.pop()
} else { } else {
state.push('math') state.push(c)
}
} else if (c === '`' || c === '(' || c === ')') {
if (state[state.length - 1] === 'code') {
state.pop()
} else {
state.push('code')
}
} else {
if (state.peek === 'escape') {
state.pop()
} }
} }
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 word += c
} else { } 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) const path = metainfoPath(word)
if (path) { if (path) {
word = `[\`${word}\`](/metainfo/${metainfoPath(word)})` word = `[\`${word}\`](/metainfo/${metainfoPath(word)})`
......
...@@ -133,13 +133,12 @@ Browser.propTypes = ({ ...@@ -133,13 +133,12 @@ Browser.propTypes = ({
export const laneContext = React.createContext() export const laneContext = React.createContext()
const useLaneStyles = makeStyles(theme => ({ const useLaneStyles = makeStyles(theme => ({
root: { root: {
minWidth: 200, width: 'min-content',
maxWidth: 512,
borderRight: `solid 1px ${grey[500]}`, borderRight: `solid 1px ${grey[500]}`,
display: 'block' display: 'inline-block'
}, },
container: { container: {
display: 'block', display: 'inline-block',
height: '100%', height: '100%',
overflowY: 'scroll' overflowY: 'scroll'
}, },
......
...@@ -156,7 +156,7 @@ export function isReference(property) { ...@@ -156,7 +156,7 @@ export function isReference(property) {
export function path(nameOrDef) { export function path(nameOrDef) {
let def let def
if (typeof nameOrDef === 'string') { if (typeof nameOrDef === 'string') {
def = defsByName[nameOrDef] && defsByName[nameOrDef].find(def => def.m_def !== 'SubSection') def = defsByName[nameOrDef] && defsByName[nameOrDef].find(def => true)
} else { } else {
def = nameOrDef def = nameOrDef
} }
...@@ -165,6 +165,10 @@ export function path(nameOrDef) { ...@@ -165,6 +165,10 @@ export function path(nameOrDef) {
return null return null
} }
if (def.m_def === 'SubSection') {
def = resolveRef(def.sub_section)
}
if (def.m_def === 'Category') { if (def.m_def === 'Category') {
return `${def._package.name.split('.')[0]}/category_definitions@${def._qualifiedName}` return `${def._package.name.split('.')[0]}/category_definitions@${def._qualifiedName}`
} }
......
...@@ -1118,8 +1118,8 @@ class BasisSet(MSection): ...@@ -1118,8 +1118,8 @@ class BasisSet(MSection):
dependent to the simulated cell as a whole). dependent to the simulated cell as a whole).
Basis sets used in this section_single_configuration_calculation, belonging to either Basis sets used in this section_single_configuration_calculation, belonging to either
class, are defined in the dedicated section: [section_basis_set_cell_dependent class, are defined in the dedicated section: section_basis_set_cell_dependent or
](section_basis_set_cell_dependent) or section_basis_set_atom_centered. The section_basis_set_atom_centered. The
correspondence between the basis sets listed in this section and the definition given correspondence between the basis sets listed in this section and the definition given
in the dedicated sessions is given by the two concrete metadata: in the dedicated sessions is given by the two concrete metadata:
mapping_section_basis_set_cell_dependent and mapping_section_basis_set_atom_centered. mapping_section_basis_set_cell_dependent and mapping_section_basis_set_atom_centered.
...@@ -1961,9 +1961,8 @@ class FrameSequenceUserQuantity(MSection): ...@@ -1961,9 +1961,8 @@ class FrameSequenceUserQuantity(MSection):
Dedicated metadata monitored along a sequence of frames are created for the Dedicated metadata monitored along a sequence of frames are created for the
conserved energy-like quantity (frame_sequence_conserved_quantity), the kinetic conserved energy-like quantity (frame_sequence_conserved_quantity), the kinetic
and potential energies ([frame_sequence_kinetic_energy and and potential energies (frame_sequence_kinetic_energy and
frame_sequence_potential_energy](frame_sequence_kinetic_energy and frame_sequence_potential_energy), the instantaneous temperature
frame_sequence_potential_energy)), the instantaneous temperature
(frame_sequence_temperature) and the pressure (frame_sequence_pressure). (frame_sequence_temperature) and the pressure (frame_sequence_pressure).
''', ''',
categories=[Unused], categories=[Unused],
...@@ -3821,8 +3820,7 @@ class Run(MSection): ...@@ -3821,8 +3820,7 @@ class Run(MSection):
''' '''
Every section_run represents a single call of a program. What exactly is contained in 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 a run depends on the run type (see for example section_method and
section_single_configuration_calculation) and the program (see [program_info section_single_configuration_calculation) and the program (see ProgramInfo).
](program_info)).
''' '''
m_def = Section( m_def = Section(
...@@ -7859,7 +7857,7 @@ class Topology(MSection): ...@@ -7859,7 +7857,7 @@ class Topology(MSection):
description=''' description='''
A unique string idenfiying the force field defined in this section. Strategies to A unique string idenfiying the force field defined in this section. Strategies to
define it are discussed in the 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). info/wikis/metainfo/topology-force-field-name).
''', ''',
a_legacy=LegacyDefinition(name='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 ...@@ -796,7 +796,13 @@ class MSection(metaclass=MObjectMeta): # TODO find a way to make this a subclas
if isinstance(attr, Property): if isinstance(attr, Property):
attr.name = name attr.name = name
if attr.description is not None: 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 attr.__doc__ = attr.description
if isinstance(attr, Quantity): if isinstance(attr, Quantity):
......
Supports Markdown
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